MCPcopy
hub / github.com/grpc/grpc-go / Serve

Method Serve

internal/testutils/fakegrpclb/server.go:126–140  ·  view source on GitHub ↗

Serve starts serving the LoadBalancer service on a gRPC server. It returns early with a non-nil error if it is unable to start serving. Otherwise, it blocks until Stop() is called, at which point it returns the error returned by the underlying grpc.Server's Serve() method.

()

Source from the content-addressed store, hash-verified

124// Otherwise, it blocks until Stop() is called, at which point it returns the
125// error returned by the underlying grpc.Server's Serve() method.
126func (s *Server) Serve() error {
127 s.mu.Lock()
128 if s.grpcServer != nil {
129 s.mu.Unlock()
130 return errors.New("Serve() called multiple times")
131 }
132
133 server := grpc.NewServer(s.sOpts...)
134 s.grpcServer = server
135 s.mu.Unlock()
136
137 logger.Infof("Begin listening on %s", s.lis.Addr().String())
138 lbgrpc.RegisterLoadBalancerServer(server, s)
139 return server.Serve(s.lis) // This call will block.
140}
141
142// Stop stops serving the LoadBalancer service and unblocks the preceding call
143// to Serve().

Callers 13

mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
startServerFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
StartManagementServerFunction · 0.95
StartServerFunction · 0.95
setupTestServerFunction · 0.95
StartManagementServerFunction · 0.95

Calls 6

NewServerFunction · 0.92
InfofMethod · 0.65
StringMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
AddrMethod · 0.45

Tested by 1

setupTestServerFunction · 0.76