Documentation ¶
Index ¶
- func NewRunner(grpcSrv *grpc.Server, lis net.Listener) *runner
- type Config
- type Server
- func (s *Server) GrpcServer() *grpc.Server
- func (s *Server) HealthService() *health.Server
- func (s *Server) OnStop(hook func(ctx context.Context) error)
- func (s *Server) Start() error
- func (s *Server) Use(interceptors ...grpc.UnaryServerInterceptor) *Server
- func (s *Server) UseStream(interceptors ...grpc.StreamServerInterceptor) *Server
- type WrappedServerStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
Server is the framework's server side instance, it contains the GrpcServer, interceptor and interceptors. Create an instance of Server, by using NewServer().
func NewServer ¶
func NewServer(conf *Config, o ...grpc.ServerOption) (s *Server)
NewServer create a grpc server instance
func (*Server) GrpcServer ¶
func (*Server) HealthService ¶
func (*Server) OnStop ¶
OnStop add stop hook to grpc server when server got terminating signal 默认传入一个10s的timeout的context
func (*Server) Start ¶
Start create a tcp listener and start goroutine for serving each incoming request. Start will block until term signal is received.
type WrappedServerStream ¶
type WrappedServerStream struct { grpc.ServerStream // WrappedContext is the wrapper's own Context. You can assign it. WrappedContext context.Context }
WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.
func WrapServerStream ¶
func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream
WrapServerStream returns a ServerStream that has the ability to overwrite context.
func (*WrappedServerStream) Context ¶
func (w *WrappedServerStream) Context() context.Context
Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()