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(name, 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) EnablePrometheus ¶
func (gs *GrpcServer) EnablePrometheus(port string)
EnablePrometheus registers prometheus metrics.
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) 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().