server

package
v0.0.0-...-e3220b9 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ChainUnaryInterceptor  = grpc.ChainUnaryInterceptor
	ChainStreamInterceptor = grpc.ChainStreamInterceptor
	UnaryInterceptor       = grpc.UnaryInterceptor
	StreamInterceptor      = grpc.StreamInterceptor
)
View Source
var (
	ErrUnknownServiceType = errors.New("unknown service type")
)

Functions

func APIPrefix

func APIPrefix(prefix string) grpc.ServerOption

APIPrefix defines grpc gateway api prefix

func Address

func Address(addr string) grpc.ServerOption

Address set server address

func ContextUnaryInterceptor

func ContextUnaryInterceptor(f func(context.Context) (context.Context, error)) grpc.UnaryServerInterceptor

func GateWayOpts

func GateWayOpts(opts ...runtime.ServeMuxOption) grpc.ServerOption

GateWayOpts provide additional options for api gateway

func Handler

func Handler(pathPrefix string, h http.Handler) grpc.ServerOption

Handler provide ability to define additional HTTP apis beside GRPC Gateway API. All HTTP API with the given prefix will be forwarded to the given handler.

func Listener

func Listener(lis net.Listener) grpc.ServerOption

Listener force server to use the given listener.

func Logger

func Logger(logger logger) grpc.ServerOption

Logger provide alternate logger for server logging

func Middlewares

func Middlewares(mdws ...middleware) grpc.ServerOption

Middlewares apply the given middleware on all HTTP requests

func NotFoundHandler

func NotFoundHandler(h http.Handler) grpc.ServerOption

NotFoundHandler provide alternative not found HTTP handler.

func OnShutdown

func OnShutdown(f func()) grpc.ServerOption

OnShutdown provide custom func to be called before shutting down

func ShutdownTimeout

func ShutdownTimeout(d time.Duration) grpc.ServerOption

ShutdownTimeout define timeout on shutdown.

func TLS

func TLS(certFile, keyFile string) grpc.ServerOption

TLS enable secure mode using tls key & cert file.

func Timeout

func Timeout(read, write time.Duration) grpc.ServerOption

Timeout set read, write timeout for internal http server.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...grpc.ServerOption) *Server

func (*Server) Address

func (srv *Server) Address() string

Address return address of the server.

func (*Server) DialOpts

func (srv *Server) DialOpts() []grpc.DialOption

DialOpts return dial options for dialling to the server.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe(ctx context.Context, services ...any) error

ListenAndServe start & serving the given services with gracefully shutdown based on context cancelling or system interrupt signals.

func (*Server) RegisterService

func (srv *Server) RegisterService(desc *grpc.ServiceDesc, impl any)

RegisterService implements grpc.ServiceRegistrar

func (*Server) ServeMux

func (srv *Server) ServeMux() *runtime.ServeMux

ServeMux return internal server multiplexer.

Jump to

Keyboard shortcuts

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