MCPcopy
hub / github.com/google/ax / Serve

Method Serve

internal/server/server.go:129–148  ·  view source on GitHub ↗

Serve starts the gRPC server on the specified address.

(address string, opts ...grpc.ServerOption)

Source from the content-addressed store, hash-verified

127
128// Serve starts the gRPC server on the specified address.
129func (s *Server) Serve(address string, opts ...grpc.ServerOption) error {
130 lis, err := net.Listen("tcp", address)
131 if err != nil {
132 return fmt.Errorf("failed to listen: %w", err)
133 }
134
135 s.grpcServer = grpc.NewServer(opts...)
136 proto.RegisterControllerServiceServer(s.grpcServer, s)
137 proto.RegisterConversationServiceServer(s.grpcServer, s)
138
139 // Register standard gRPC Health Check server
140 hs := health.NewServer()
141 hs.SetServingStatus("AX", grpc_health_v1.HealthCheckResponse_SERVING)
142 grpc_health_v1.RegisterHealthServer(s.grpcServer, hs)
143
144 if err := s.grpcServer.Serve(lis); err != nil {
145 return fmt.Errorf("failed to serve: %w", err)
146 }
147 return nil
148}
149
150// GracefulStop stops the gRPC server gracefully.
151func (s *Server) GracefulStop() {

Callers 6

startMockGRPCServerFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
runServeFunction · 0.80
serveTraceUIFunction · 0.80

Tested by 1

startMockGRPCServerFunction · 0.76