server

package
v0.0.0-...-c2aaf4c Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: BSD-3-Clause Imports: 9 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 GRPC

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

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

func NewGRPC

func NewGRPC(port string, options ...grpc.ServerOption) *GRPC

NewGRPC creates an instance of GRPC.

func (*GRPC) AwaitTermination

func (g *GRPC) AwaitTermination() error

AwaitTerminations 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.

func (*GRPC) RegisterServices

func (g *GRPC) RegisterServices(fns ...RegisterServiceFunc)

RegisterServices registers gRPC service to gRPC server.

func (*GRPC) Run

func (g *GRPC) Run() error

Run runs the server. It basically runs grpc.Server.Serve in a goroutine. So, it is not blocking.

type RegisterEndpointFunc

type RegisterEndpointFunc func(server *runtime.ServeMux) error

RegisterEndpointFunc defines function contract to register endpoint.

type RegisterServiceFunc

type RegisterServiceFunc func(server *grpc.Server)

RegisterServiceFunc defines function contract to register service.

type Rest

type Rest struct {
	*runtime.ServeMux
	// contains filtered or unexported fields
}

Rest is responsible to act as HTTP/1.1 REST server. It composes grpc-gateway runtime.ServeMux.

func NewRest

func NewRest(port string) *Rest

NewRest creates an instance of Rest.

func (*Rest) EnablePrometheus

func (r *Rest) EnablePrometheus() error

EnablePrometheus enables prometheus endpoint. It can be accessed via /metrics.

func (*Rest) RegisterEndpoints

func (r *Rest) RegisterEndpoints(fns ...RegisterEndpointFunc) error

RegisterEndpoints registers HTTP/1.1 REST endpoints. If there are some errors, it returns the first error it encounter and stop the iteration.

func (*Rest) Run

func (r *Rest) Run() error

Run runs HTTP/1.1 runtime.ServeMux. It is blocking.

Jump to

Keyboard shortcuts

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