Skip to content

Commit 0da1bd6

Browse files
committed
server: add grpc registration methods
To avoid us forgetting to register new services added to tapd when integrating into litd, we now expose two new methods that we can call from litd instead of doing the registration there manually.
1 parent 7d111bb commit 0da1bd6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

server.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,35 @@ func startRestProxy(cfg *Config, rpcServer *rpcServer,
669669
return shutdown, nil
670670
}
671671

672+
// RegisterGrpcService must register the sub-server's GRPC server with the given
673+
// registrar.
674+
//
675+
// NOTE: this is part of the SubServer interface.
676+
func (s *Server) RegisterGrpcService(registrar grpc.ServiceRegistrar) {
677+
_ = s.rpcServer.RegisterWithGrpcServer(registrar)
678+
_ = s.mboxServer.RegisterWithGrpcServer(registrar)
679+
}
680+
681+
// RegisterRestService registers the sub-server's REST handlers with the given
682+
// endpoint.
683+
//
684+
// NOTE: this is part of the SubServer interface.
685+
func (s *Server) RegisterRestService(ctx context.Context, mux *proxy.ServeMux,
686+
endpoint string, dialOpts []grpc.DialOption) error {
687+
688+
err := s.rpcServer.RegisterWithRestProxy(ctx, mux, dialOpts, endpoint)
689+
if err != nil {
690+
return err
691+
}
692+
693+
err = s.mboxServer.RegisterWithRestProxy(ctx, mux, dialOpts, endpoint)
694+
if err != nil {
695+
return err
696+
}
697+
698+
return nil
699+
}
700+
672701
// Stop signals that the main tapd server should attempt a graceful shutdown.
673702
func (s *Server) Stop() error {
674703
if atomic.AddInt32(&s.shutdown, 1) != 1 {

0 commit comments

Comments
 (0)