server

package
v0.0.0-...-26a0867 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package server provides a wrapper around the grpc.Server.

Index

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 WithAddress

func WithAddress(addr string) Option

WithAddress sets server address.

func WithListener

func WithListener(l net.Listener, shouldCloseListener bool) Option

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 WithPort

func WithPort(port int) Option

WithPort sets server address port.

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.

func WithService

func WithService(s ServiceServer) Option

WithService registers a service.

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 NewServer

func NewServer(opts ...Option) *Server

NewServer initiates a new wrapped grpc server.

func (*Server) Addr

func (s *Server) Addr() string

Addr service address.

func (*Server) Listener

func (s *Server) Listener() net.Listener

Listener returns the listener.

func (*Server) Name

func (s *Server) Name() string

Name Service name.

func (*Server) Start

func (s *Server) Start() error

Start begins listening and serving.

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.

Jump to

Keyboard shortcuts

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