server

package
v0.0.0-...-3fe35c7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcConfig

type GrpcConfig struct {
	Port        string        `mapstructure:"grpc-port"`
	GracePeriod time.Duration `mapstructure:"grpc-grace-period"`
}

HttpConfig defines all configuration fields for the gRPC server

type GrpcServer

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

GrpcServer defines the default behaviour of gRPC servers

func NewGrpcServer

func NewGrpcServer(logger *zap.Logger, config *GrpcConfig) *GrpcServer

NewGrpcServer returns a new, pre-initialized, GrpcServer instance The application will terminate if the server cannot bind to the configured port. If the application does not terminate, the port is open and a raw gRPC server has been created after the call of NewGrpcServer() 'tracer' may be nil, in this case the feature is disabled

func (*GrpcServer) Health

func (srv *GrpcServer) Health() http.HandlerFunc

Health returns a http.HandlerFunc, it reports the gRPC server health: OK or UNHEALTHY

func (*GrpcServer) ListenAndServe

func (srv *GrpcServer) ListenAndServe(ctx context.Context, wg *sync.WaitGroup)

ListenAndServe ties everything together and runs the gRPC server in a separate goroutine. The method then blocks until the passed context is cancelled, so this method should also be started as goroutine if more work is needed after starting the gRPC server.

type HttpConfig

type HttpConfig struct {
	Port        string        `mapstructure:"http-port"`
	GracePeriod time.Duration `mapstructure:"http-grace-period"`
}

type HttpServer

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

func NewHttpServer

func NewHttpServer(logger *zap.Logger, config *HttpConfig) *HttpServer

func (*HttpServer) Health

func (srv *HttpServer) Health() http.HandlerFunc

Health returns a http.HandlerFunc, it reports the gRPC server health: OK or UNHEALTHY

func (*HttpServer) ListenAndServe

func (srv *HttpServer) ListenAndServe(ctx context.Context, wg *sync.WaitGroup, handler http.Handler)

Jump to

Keyboard shortcuts

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