gserver

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GRPCRegistrator

type GRPCRegistrator interface {
	RegisterGRPC(*grpc.Server)
}

GRPCRegistrator provides interface to register gRPC service

type RouteRegistrator

type RouteRegistrator interface {
	RegisterRoute(rest.Router)
}

RouteRegistrator provides interface to register HTTP route

type Server

type Server struct {
	Listeners []net.Listener
	// contains filtered or unexported fields
}

Server contains a running trusty server and its listeners.

func Start

func Start(
	name string,
	cfg *config.HTTPServer,
	container *dig.Container,
	serviceFactories map[string]ServiceFactory,
) (e *Server, err error)

Start returns running Server

func (*Server) AddService

func (e *Server) AddService(svc Service)

AddService to the server

func (*Server) Audit

func (e *Server) Audit(
	source string,
	eventType string,
	identity string,
	contextID string,
	raftIndex uint64,
	message string)

Audit create an audit event

func (*Server) Close

func (e *Server) Close()

Close gracefully shuts down all servers/listeners. Client requests will be terminated with request timeout. After timeout, enforce remaning requests be closed immediately.

func (*Server) Configuration

func (e *Server) Configuration() *config.HTTPServer

Configuration of the server

func (*Server) Discovery

func (e *Server) Discovery() appcontainer.Discovery

Discovery returns Discovery interface

func (*Server) Err

func (e *Server) Err() <-chan error

Err returns error channel

func (*Server) Hostname

func (e *Server) Hostname() string

Hostname is the hostname

func (*Server) IsReady

func (e *Server) IsReady() bool

IsReady returns true when the server is ready to serve

func (*Server) ListenURLs

func (e *Server) ListenURLs() []string

ListenURLs is the list of URLs that the server listens on

func (*Server) LocalIP

func (e *Server) LocalIP() string

LocalIP is the local IP4

func (*Server) Name

func (e *Server) Name() string

Name returns server name

func (*Server) Service

func (e *Server) Service(name string) Service

Service returns service by name

func (*Server) StartedAt

func (e *Server) StartedAt() time.Time

StartedAt returns Time when the server has started

type Service

type Service interface {
	Name() string
	Close()
	// IsReady indicates that service is ready to serve its end-points
	IsReady() bool
}

Service provides a way for subservices to be registered so they get added to the http API.

type ServiceFactory

type ServiceFactory func(*Server) interface{}

ServiceFactory is interface to create Services

type StartSubcriber

type StartSubcriber interface {
	// OnStarted is called when the server started and
	// is ready to serve requests
	OnStarted() error
}

StartSubcriber provides

Jump to

Keyboard shortcuts

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