server

package
v0.0.0-...-91ee7f2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: BSD-3-Clause Imports: 20 Imported by: 4

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 Config

type Config struct {
	Name                     string
	Port                     string
	Username                 string
	Password                 string
	AppliedBearerAuthMethods []string
	AppliedBasicAuthMethods  []string
	Secret                   []byte
}

Config represents server's config.

type Server

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

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

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates an instance of Server 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 (*Server) AttachService

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

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

func (*Server) EnablePrometheus

func (gs *Server) EnablePrometheus(port string)

EnablePrometheus registers prometheus metrics.

func (*Server) GracefulStop

func (gs *Server) 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 (*Server) Name

func (gs *Server) Name() string

Name returns server's name.

func (*Server) Port

func (gs *Server) Port() string

Port returns server's port.

func (*Server) Serve

func (gs *Server) Serve() error

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

func (*Server) Stop

func (gs *Server) 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