Documentation ¶
Overview ¶
Package server provides a wrapper around the grpc.Server.
Index ¶
- type InitGRPCServiceConfig
- type Option
- func ChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) Option
- func ChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) Option
- func WithAddrAssigned() Option
- func WithAddress(addr string) Option
- func WithListener(l net.Listener, shouldCloseListener bool) Option
- func WithMetrics(metrics *grpcPrometheus.ServerMetrics) Option
- func WithPort(port int) Option
- func WithReflective() Option
- func WithServerOption(opts ...grpc.ServerOption) Option
- func WithService(s ServiceServer) Option
- type Server
- type ServiceServer
- type ServiceServerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InitGRPCServiceConfig ¶
type InitGRPCServiceConfig struct { Listener net.Listener Service ServiceServer Logger *zap.Logger UInterceptor []grpc.UnaryServerInterceptor WithReflective bool Options []Option }
type Option ¶
type Option func(srv *Server)
Option sets up a server.
func ChainStreamInterceptor ¶
func ChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) Option
ChainStreamInterceptor sets the server interceptors for stream.
func ChainUnaryInterceptor ¶
func ChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) Option
ChainUnaryInterceptor sets the server interceptors for unary.
func WithAddrAssigned ¶
func WithAddrAssigned() Option
WithAddrAssigned sets service to ask for listener assigned address. Mainly used when the port to the listener is assigned dynamically.
func WithListener ¶
WithListener sets the listener. Server does not need to start a new one.
func WithMetrics ¶
func WithMetrics(metrics *grpcPrometheus.ServerMetrics) Option
WithMetrics sets the metrics, metrics handler and metrics listener. Used to initialize all metrics and create http.Serve for /metrics endpoint.
func WithReflective ¶
func WithReflective() Option
WithReflective sets service reflective so that APIs can be discovered.
func WithServerOption ¶
func WithServerOption(opts ...grpc.ServerOption) Option
WithServerOption sets the options for the grpc server.
type Server ¶
type Server struct { AddrAssigned chan string // contains filtered or unexported fields }
Server is a wrapper around grpc.Server.
func InitGRPCService ¶
func InitGRPCService( _ context.Context, cfg InitGRPCServiceConfig, ) (*Server, error)
InitGRPCService initialize an instance of grpc service, with all the instrumentation.
func (*Server) WithShutdownSignal ¶
func (s *Server) WithShutdownSignal(shutdown <-chan struct{}, done chan<- struct{}) servicing.Service
WithShutdownSignal adds channels to wait for shutdown and to report shutdown finished.
type ServiceServer ¶
type ServiceServer interface {
RegisterService(s grpc.ServiceRegistrar)
}
ServiceServer is an interface for a server that provides services.
type ServiceServerFunc ¶
type ServiceServerFunc func(s grpc.ServiceRegistrar)
ServiceServerFunc is the function to register service to a service registrar.