Documentation ¶
Index ¶
- Variables
- type Option
- func WithAddr(addr string) Option
- func WithGRPCOptions(opts ...grpc.ServerOption) Option
- func WithListener(listener net.Listener) Option
- func WithLogger(logger xlog.Logger) Option
- func WithMetadata(metadata map[string]string) Option
- func WithMiddlewares(mws ...middleware.Middleware) Option
- func WithName(name string) Option
- func WithNetwork(network string) Option
- func WithRegistrar(registrar sd.Registrar) Option
- func WithTLSConfig(tls *tls.Config) Option
- func WithTimeout(timeout time.Duration) Option
- type Server
- func (s *Server) GracefulStop()
- func (s *Server) Healthz(ctx context.Context) bool
- func (s *Server) Offline(ctx context.Context) error
- func (s *Server) Online(ctx context.Context) error
- func (s *Server) Start() (err error)
- func (s *Server) Stop()
- func (s *Server) Use(selector string, mws ...middleware.Middleware)
Constants ¶
This section is empty.
Variables ¶
var ( UnableToGetPort = errors.New("unable to get port") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(o *options)
Option is a function that configures the server.
func WithGRPCOptions ¶
func WithGRPCOptions(opts ...grpc.ServerOption) Option
WithGRPCOptions returns an Option that sets the grpc options of the server.
func WithListener ¶
WithListener returns an Option that sets the listener of the server.
func WithLogger ¶
WithLogger returns an Option that sets the logger of the server.
func WithMetadata ¶
WithMetadata returns an Option that sets the metadata of the server.
func WithMiddlewares ¶
func WithMiddlewares(mws ...middleware.Middleware) Option
WithMiddlewares returns an Option that sets the middlewares of the server.
func WithNetwork ¶
WithNetwork returns an Option that sets the network of the server.
func WithRegistrar ¶
WithRegistrar returns an Option that sets the register of the server.
func WithTLSConfig ¶
WithTLSConfig returns an Option that sets the tls config of the server.
func WithTimeout ¶
WithTimeout returns an Option that sets the timeout of the server.
type Server ¶
Server is a grpc server.
func (*Server) GracefulStop ¶
func (s *Server) GracefulStop()
GracefulStop stops the server gracefully.
func (*Server) Offline ¶
Offline sets the health status of the server to NOT_SERVING. deregisters the server from the service discovery.
func (*Server) Online ¶
Online sets the health status of the server to SERVING. registers the server to the service discovery.
func (*Server) Use ¶
func (s *Server) Use(selector string, mws ...middleware.Middleware)
Use adds middleware to the server. selector support /, /{package} /{package}.{service}, /{package}.{service}/{method}