server

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnavailableAddr = errors.New("unavailable addr")
	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 WithAddr

func WithAddr(addr string) Option

WithAddr returns an Option that sets the address of the server.

func WithGRPCOptions

func WithGRPCOptions(opts ...grpc.ServerOption) Option

WithGRPCOptions returns an Option that sets the grpc options of the server.

func WithListener

func WithListener(listener net.Listener) Option

WithListener returns an Option that sets the listener of the server.

func WithLogger

func WithLogger(logger xlog.Logger) Option

WithLogger returns an Option that sets the logger of the server.

func WithMetadata

func WithMetadata(metadata map[string]string) Option

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 WithName

func WithName(name string) Option

WithName returns an Option that sets the name of the server.

func WithNetwork

func WithNetwork(network string) Option

WithNetwork returns an Option that sets the network of the server.

func WithRegistrar

func WithRegistrar(registrar sd.Registrar) Option

WithRegistrar returns an Option that sets the register of the server.

func WithTLSConfig

func WithTLSConfig(tls *tls.Config) Option

WithTLSConfig returns an Option that sets the tls config of the server.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout returns an Option that sets the timeout of the server.

type Server

type Server struct {
	*grpc.Server
	// contains filtered or unexported fields
}

Server is a grpc server.

func New

func New(optFns ...Option) (*Server, error)

New creates a new grpc server.

func (*Server) GracefulStop

func (s *Server) GracefulStop()

GracefulStop stops the server gracefully.

func (*Server) Healthz

func (s *Server) Healthz(ctx context.Context) bool

Healthz returns the health status of the server.

func (*Server) Offline

func (s *Server) Offline(ctx context.Context) error

Offline sets the health status of the server to NOT_SERVING. deregisters the server from the service discovery.

func (*Server) Online

func (s *Server) Online(ctx context.Context) error

Online sets the health status of the server to SERVING. registers the server to the service discovery.

func (*Server) Start

func (s *Server) Start() (err error)

Start starts the server.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

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}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL