diff --git a/client/connection_rdma.go b/client/connection_rdma.go index 6c0cebb2..1417681d 100644 --- a/client/connection_rdma.go +++ b/client/connection_rdma.go @@ -1,5 +1,5 @@ -//go:build linux -// +build linux +//go:build rdma +// +build rdma package client diff --git a/server/listener_linux.go b/server/listener_linux.go index 93535070..aa72d77c 100644 --- a/server/listener_linux.go +++ b/server/listener_linux.go @@ -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. @@ -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) -} diff --git a/server/listener_rdma.go b/server/listener_rdma.go new file mode 100644 index 00000000..ddbaffa0 --- /dev/null +++ b/server/listener_rdma.go @@ -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) +}