Skip to content

Commit

Permalink
Deprecate NewServerSocket
Browse files Browse the repository at this point in the history
Summary: Deprecate NewServerSocket.

Reviewed By: leoleovich

Differential Revision: D64497056

fbshipit-source-id: 6e30cadbc446209d53c961393d5ef7da32c67043
  • Loading branch information
echistyakov authored and facebook-github-bot committed Nov 1, 2024
1 parent 5963809 commit 9edb038
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions thrift/conformance/go/conformance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ func main() {
}

func newServer(processor thrift.Processor, addr string) (thrift.Server, net.Addr, error) {
socket, err := thrift.NewServerSocket(addr)
listener, err := thrift.NewListener(addr)
if err != nil {
return nil, nil, err
}
return thrift.NewSimpleServer(processor, socket, thrift.TransportIDUpgradeToRocket), socket.Addr(), nil
return thrift.NewSimpleServer(processor, listener, thrift.TransportIDUpgradeToRocket), listener.Addr(), nil
}

type dataConformanceServiceHandler struct {
Expand Down
4 changes: 2 additions & 2 deletions thrift/conformance/go/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func main() {
}

func newServer(processor thrift.Processor, addr string) (thrift.Server, net.Addr, error) {
socket, err := thrift.NewServerSocket(addr)
listener, err := thrift.NewListener(addr)
if err != nil {
return nil, nil, err
}
return thrift.NewSimpleServer(processor, socket, thrift.TransportIDRocket), socket.Addr(), nil
return thrift.NewSimpleServer(processor, listener, thrift.TransportIDRocket), listener.Addr(), nil
}

type rpcConformanceServiceHandler struct {
Expand Down
5 changes: 0 additions & 5 deletions thrift/lib/go/thrift/server_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import (
"net"
)

// Deprecated: NewServerSocket rather use NewListener.
func NewServerSocket(listenAddr string) (net.Listener, error) {
return NewListener(listenAddr)
}

// NewListener creates a new net.Listener bound to the given address.
func NewListener(listenAddr string) (net.Listener, error) {
addr, err := net.ResolveTCPAddr("tcp", listenAddr)
Expand Down
4 changes: 2 additions & 2 deletions thrift/perf/go/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func Serve(addr string) error {
}

func newServer(processor thrift.Processor, addr string) (thrift.Server, error) {
socket, err := thrift.NewServerSocket(addr)
listener, err := thrift.NewListener(addr)
if err != nil {
return nil, err
}
return thrift.NewSimpleServer(processor, socket, thrift.TransportIDUpgradeToRocket), nil
return thrift.NewSimpleServer(processor, listener, thrift.TransportIDUpgradeToRocket), nil
}

// Echo - does echo
Expand Down
6 changes: 3 additions & 3 deletions thrift/test/go/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ func createTestHeaderServer(handler thrifttest.ThriftTest) (context.CancelFunc,
ctx, cancel := context.WithCancel(context.Background())
processor := thrifttest.NewThriftTestProcessor(handler)

transport, err := thrift.NewServerSocket("[::]:0")
listener, err := thrift.NewListener("[::]:0")
if err != nil {
return cancel, nil, fmt.Errorf("failed to open test socket: %w", err)
}
taddr := transport.Addr()
taddr := listener.Addr()

server := thrift.NewSimpleServer(processor, transport, thrift.TransportIDHeader)
server := thrift.NewSimpleServer(processor, listener, thrift.TransportIDHeader)
go func(server thrift.Server) {
err = server.ServeContext(ctx)
if err != nil && !errors.Is(err, context.Canceled) {
Expand Down

0 comments on commit 9edb038

Please sign in to comment.