server

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*serverOpts)

Option is an optional setting applied to the Server.

func WithGRPCOpts

func WithGRPCOpts(opts []grpc.ServerOption) Option

WithGRPCOpts sets gRPC server options.

func WithGRPCStreamMiddlewares

func WithGRPCStreamMiddlewares(mws ...grpc.StreamServerInterceptor) Option

WithGRPCStreamMiddlewares sets up stream middlewares for gRPC server.

func WithGRPCUnaryMiddlewares

func WithGRPCUnaryMiddlewares(mws ...grpc.UnaryServerInterceptor) Option

WithGRPCUnaryMiddlewares sets up unary middlewares for gRPC server.

func WithHTTPMiddlewares

func WithHTTPMiddlewares(mws ...mwhttp.Middleware) Option

WithHTTPMiddlewares sets up HTTP middlewares to work with.

func WithHTTPMux

func WithHTTPMux(mux *chi.Mux) Option

WithHTTPMux sets existing HTTP muxer to use instead of creating new one.

func WithHTTPPort

func WithHTTPPort(port int) Option

WithHTTPPort sets HTTP RPC port to listen on. Set same port as main to use single port.

func WithHTTPRouterMux

func WithHTTPRouterMux(mux transport.Router) Option

type Server

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

Server is a transport server.

func NewServer

func NewServer(rpcPort int, opts ...Option) *Server

NewServer creates a Server listening on the rpcPort. Pass additional Options to mutate its behaviour. By default, HTTP JSON handler and gRPC are listening on the same port, admin port is p+2 and profile port is p+4.

func (*Server) Run

func (s *Server) Run(svc transport.Service) error

Run starts processing requests to the service. It blocks indefinitely, run asynchronously to do anything after that.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server gracefully.

Directories

Path Synopsis
middlewares
mwgrpc
Package mwgrpc provides common gRPC middlewares.
Package mwgrpc provides common gRPC middlewares.

Jump to

Keyboard shortcuts

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