Skip to content

Commit

Permalink
make thrift.SimpleServer private
Browse files Browse the repository at this point in the history
Summary: make thrift.SimpleServer private

Reviewed By: podtserkovskiy

Differential Revision: D60038069

fbshipit-source-id: 6d81d630662986689dc02d1ebb5345fd089d5f2c
  • Loading branch information
Walter Schulze authored and facebook-github-bot committed Jul 22, 2024
1 parent bee5781 commit 1e426a5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions thrift/lib/go/thrift/simple_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"runtime/debug"
)

// SimpleServer is a functional but unoptimized server that is easy to
// simpleServer is a functional but unoptimized server that is easy to
// understand. In its accept loop, it performs an accept on an
// underlying socket, wraps the socket in the net.Listener, and
// then spins up a gofunc to process requests.
Expand All @@ -34,7 +34,7 @@ import (
// on the connection. multiple simultaneous requests over a single
// connection are not supported, as the per-connection gofunc reads
// the request, processes it, and writes the response serially
type SimpleServer struct {
type simpleServer struct {
processor ProcessorContext
listener net.Listener
newProtocol func(net.Conn) (Protocol, error)
Expand All @@ -43,11 +43,11 @@ type SimpleServer struct {
}

// NewSimpleServer creates a new server that only supports Header Transport.
func NewSimpleServer(processor ProcessorContext, listener net.Listener, transportType TransportID, options ...func(*ServerOptions)) *SimpleServer {
func NewSimpleServer(processor ProcessorContext, listener net.Listener, transportType TransportID, options ...func(*ServerOptions)) Server {
if transportType != TransportIDHeader {
panic(fmt.Sprintf("SimpleServer only supports Header Transport and not %d", transportType))
}
return &SimpleServer{
return &simpleServer{
processor: processor,
listener: listener,
newProtocol: NewHeaderProtocol,
Expand All @@ -66,7 +66,7 @@ func simpleServerOptions(options ...func(*ServerOptions)) *ServerOptions {

// ServeContext starts listening on the transport and accepting new connections
// and blocks until cancel is called via context or an error occurs.
func (p *SimpleServer) ServeContext(ctx context.Context) error {
func (p *simpleServer) ServeContext(ctx context.Context) error {
go func() {
<-ctx.Done()
p.listener.Close()
Expand All @@ -79,7 +79,7 @@ func (p *SimpleServer) ServeContext(ctx context.Context) error {
}

// acceptLoop takes a context that will be decorated with ConnInfo and passed down to new clients.
func (p *SimpleServer) acceptLoop(ctx context.Context) error {
func (p *simpleServer) acceptLoop(ctx context.Context) error {
for {
conn, err := p.listener.Accept()
if err != nil {
Expand All @@ -102,7 +102,7 @@ func (p *SimpleServer) acceptLoop(ctx context.Context) error {
}
}

func (p *SimpleServer) processRequests(ctx context.Context, conn net.Conn) error {
func (p *simpleServer) processRequests(ctx context.Context, conn net.Conn) error {
protocol, err := p.newProtocol(conn)
if err != nil {
return err
Expand Down

0 comments on commit 1e426a5

Please sign in to comment.