server

package
v0.0.0-...-58ae5d1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package server provides HTTP/2 gRCP server functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcServer

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

GrpcServer is responsible to act as gRPC server. It composes grpc.Server.

func NewGrpcServer

func NewGrpcServer(port string) *GrpcServer

NewGrpcServer creates an instance of GrpcServer for used in development environment.

These are list of interceptors that are attached (from innermost to outermost):

  • Metrics, using Prometheus.
  • Logging, using zap logger.
  • Recoverer, using grpcrecovery.

func (*GrpcServer) AttachService

func (gs *GrpcServer) AttachService(fn func(*grpc.Server))

AttachService attaches service to gRPC server. It will be called before serve.

func (*GrpcServer) GracefulStop

func (gs *GrpcServer) GracefulStop()

GracefulStop blocks the server and wait for termination signal. The termination signal must be one of SIGINT or SIGTERM. Once it receives one of those signals, the gRPC server will perform graceful stop and close the listener.

It receives Closer and will perform all closers before closing itself.

func (*GrpcServer) Name

func (gs *GrpcServer) Name() string

Name returns server's name.

func (*GrpcServer) Port

func (gs *GrpcServer) Port() string

Port returns server's port.

func (*GrpcServer) Serve

func (gs *GrpcServer) Serve() error

Serve runs the server. It basically runs grpc.Server.Serve and is a blocking.

func (*GrpcServer) Stop

func (gs *GrpcServer) Stop()

Stop immediately stops the gRPC server. Currently, this method exists just for the sake of testing. For production purpose, use GracefulStop().

Jump to

Keyboard shortcuts

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