Skip to content

Commit

Permalink
#883 use the rdma build tag
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoyuepan committed Dec 2, 2024
1 parent 60a3812 commit 4ffba56
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
4 changes: 2 additions & 2 deletions client/connection_rdma.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build linux
// +build linux
//go:build rdma
// +build rdma

package client

Expand Down
24 changes: 0 additions & 24 deletions server/listener_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ package server

import (
"net"
"os"
"runtime"
"strconv"
"time"

uringnet "github.com/godzie44/go-uring/net"
"github.com/godzie44/go-uring/reactor"
"github.com/godzie44/go-uring/uring"
"github.com/smallnest/rpcx/log"
"github.com/smallnest/rsocket"
)

func init() {
makeListeners["iouring"] = iouringMakeListener
makeListeners["rdma"] = rdmaMakeListener
}

// iouringMakeListener creates a new listener using io_uring.
Expand Down Expand Up @@ -68,23 +64,3 @@ type uringLogger struct {
func (l *uringLogger) Log(keyvals ...interface{}) {
l.Logger.Info(keyvals...)
}

func rdmaMakeListener(s *Server, address string) (ln net.Listener, err error) {
host, port, err := net.SplitHostPort(address)
if err != nil {
return nil, err
}
p, err := strconv.Atoi(port)
if err != nil {
return nil, err
}
backlog := os.Getenv("RDMA_BACKLOG")
if backlog == "" {
backlog = "128"
}
blog, _ := strconv.Atoi(backlog)
if blog == 0 {
blog = 128
}
return rsocket.NewTCPListener(host, p, blog)
}
36 changes: 36 additions & 0 deletions server/listener_rdma.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//go:build rdma
// +build rdma

package server

import (
"net"
"os"
"strconv"

"github.com/smallnest/rsocket"
)

func init() {
makeListeners["rdma"] = rdmaMakeListener
}

func rdmaMakeListener(s *Server, address string) (ln net.Listener, err error) {
host, port, err := net.SplitHostPort(address)
if err != nil {
return nil, err
}
p, err := strconv.Atoi(port)
if err != nil {
return nil, err
}
backlog := os.Getenv("RDMA_BACKLOG")
if backlog == "" {
backlog = "128"
}
blog, _ := strconv.Atoi(backlog)
if blog == 0 {
blog = 128
}
return rsocket.NewTCPListener(host, p, blog)
}

0 comments on commit 4ffba56

Please sign in to comment.