serverpool

package
v0.0.0-...-ffea4ed Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiagnosticsServer

type DiagnosticsServer struct {
	http.Server
	Router *mux.Router
	// contains filtered or unexported fields
}

func NewDiagnosticsServer

func NewDiagnosticsServer(port int, l logger.Logger) *DiagnosticsServer

func (*DiagnosticsServer) Address

func (s *DiagnosticsServer) Address() string

func (*DiagnosticsServer) Ready

func (s *DiagnosticsServer) Ready(v bool)

func (*DiagnosticsServer) Start

func (s *DiagnosticsServer) Start() error

func (*DiagnosticsServer) Stop

func (s *DiagnosticsServer) Stop(ctx context.Context) error

type Item

type Item struct {
	Name   string
	Server Server
}

Item contains a name and a Server implementation

type Pool

type Pool struct {
	Items []Item
	// contains filtered or unexported fields
}

Pool is used to manage Server implementationsl. Pool contains functions to gracefully take care of starting and stopping multiple servers

func New

func New(l logger.Logger, items ...Item) *Pool

func (*Pool) Ready

func (p *Pool) Ready(v bool)

Ready is used to signal all relevant items that the pool is ready

func (*Pool) Start

func (p *Pool) Start() (chan os.Signal, chan error)

Start will start all servers in the pool. It returns a channel for operating system signals and errors

func (*Pool) Stop

func (p *Pool) Stop()

Stop loops over all items and executes a graceful shutdown with a timeout of 1 minute TODO: More flexible timeout

type Server

type Server interface {
	// Start starts a server
	Start() error

	// Stop gracefully shutdsown a server
	Stop(context.Context) error

	// Address returns a string containing the address the server runs on
	Address() string
}

Server is an interface for servers which are to be used as a PoolItem

type Signaler

type Signaler interface {
	Ready(bool)
}

Signaler is used for objects which require to be signalled when the server is ready

Jump to

Keyboard shortcuts

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