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 ¶ added in v0.1.5
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.
func (*Server) Use ¶
func (s *Server) Use(interceptors ...grpc.UnaryServerInterceptor) *Server
Use attachs a global inteceptor to the server. For example, this is the right place for a rate limiter or error management inteceptor. This function is not concurrency safe.
func (*Server) UseStream ¶ added in v0.1.8
func (s *Server) UseStream(interceptors ...grpc.StreamServerInterceptor) *Server
UseStream attachs a global inteceptor to the server. For example, this is the right place for a rate limiter or error management inteceptor. This function is not concurrency safe.
type WrappedServerStream ¶ added in v0.1.8
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 ¶ added in v0.1.8
func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream
WrapServerStream returns a ServerStream that has the ability to overwrite context.
func (*WrappedServerStream) Context ¶ added in v0.1.8
func (w *WrappedServerStream) Context() context.Context
Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()