Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct { // service properties AppName string ConfigFileName string CustomConfigPath string // register one or more service handlers // example: type AnswerServiceImpl struct { // testpb.UnimplementedAnswerServiceServer // } // // RegisterServiceHandlers: func(grpcServer *grpc.Server) { // testpb.RegisterAnswerServiceServer(grpcServer, &AnswerServiceImpl{}) // }, RegisterServiceHandlers func(grpcServer *grpc.Server) // setup optional health check handlers DefaultHealthCheckHandler func(ctx context.Context) grpc_health_v1.HealthCheckResponse_ServingStatus ServiceHealthCheckHandlers map[string]func(ctx context.Context) grpc_health_v1.HealthCheckResponse_ServingStatus // setup optional rate limit server interceptor RateLimit ratelimiter.RateLimiterIFace // one or more unary server interceptors for handling wrapping actions UnaryServerInterceptors []grpc.UnaryServerInterceptor // one or more stream server interceptors for handling wrapping actions StreamServerInterceptors []grpc.StreamServerInterceptor // typically wrapper action to handle monitoring StatsHandler stats.Handler // handler for unknown requests rather than sending back an error UnknownStreamHandler grpc.StreamHandler // handler to invoke before gRPC server is to start BeforeServerStart func(svc *Service) // handler to invoke after gRPC server started AfterServerStart func(svc *Service) // handler to invoke before gRPC server is to shutdown BeforeServerShutdown func(svc *Service) // handler to invoke after gRPC server has shutdown AfterServerShutdown func(svc *Service) // contains filtered or unexported fields }
Service represents a gRPC server's service definition and entry point
AppName = (required) name of this service ConfigFileName = (required) config file name without .yaml extension CustomConfigPath = (optional) if not specified, . is assumed RegisterServiceHandlers = (required) func to register grpc service handlers
func NewService ¶
func NewService(appName string, configFileName string, customConfigPath string, registerServiceHandlers func(grpcServer *grpc.Server)) *Service
create service
func (*Service) CurrentlyServing ¶
CurrentlyServing indicates if this service health status indicates currently serving mode or not
func (*Service) GracefulStop ¶
func (s *Service) GracefulStop()
GracefulStop allows existing actions be completed before shutting down gRPC server
func (*Service) ImmediateStop ¶
func (s *Service) ImmediateStop()
ImmediateStop will forcefully shutdown gRPC server regardless of pending actions being processed
func (*Service) LocalAddress ¶
LocalAddress returns the service server's address and port