server

package
v0.0.0-...-9abd940 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TCPControl

func TCPControl(network, address string, c syscall.RawConn) error

TCPControl set of flags of TCP listener to reuse the socket when the service needs to be restored. This function will work only for unix systems. To port it to other systems, we advise to use the external lib go-reuseport. https://github.com/libp2p/go-reuseport/blob/master/control_unix.go

Types

type HCControllerOpts

type HCControllerOpts struct {
	Event       *event.EventHandler
	Metric      *metric.MetricsHandler
	TermTimeout uint64
}

type HealthCheckController

type HealthCheckController struct {
	// Healthy flag. Return true when the termination
	// flag is not set.
	Healthy bool

	HealthSince   time.Time
	UnhealthSince time.Time

	Event *event.EventHandler

	Metric *metric.MetricsHandler
	// contains filtered or unexported fields
}

func NewHealthCheckController

func NewHealthCheckController(op *HCControllerOpts) *HealthCheckController

func (*HealthCheckController) GetHealthy

func (hc *HealthCheckController) GetHealthy() bool

func (*HealthCheckController) GetHealthyStr

func (hc *HealthCheckController) GetHealthyStr() string

Returns healthy/unhealthy string

func (*HealthCheckController) Start

func (hc *HealthCheckController) Start()

func (*HealthCheckController) StartHealth

func (hc *HealthCheckController) StartHealth()

func (*HealthCheckController) StartTermination

func (hc *HealthCheckController) StartTermination()

func (*HealthCheckController) StartUnhealth

func (hc *HealthCheckController) StartUnhealth()

func (*HealthCheckController) StopTermination

func (hc *HealthCheckController) StopTermination()

type Listener

type Listener struct {
	Event *event.EventHandler
	// contains filtered or unexported fields
}

func NewListener

func NewListener(op *ListenerOptions) (*Listener, error)

func (*Listener) Start

func (l *Listener) Start() error

type ListenerOptions

type ListenerOptions struct {
	ServiceProto       Protocol
	ServicePort        uint64
	HCProto            Protocol
	HCPort             uint64
	HCPath             string
	TargetGroupARN     string
	CertPem            string
	CertKey            string
	TerminationTimeout uint64
	Event              *event.EventHandler
	Metric             *metric.MetricsHandler
	Debug              bool
}

type Protocol

type Protocol uint8
const (
	ProtoTCP Protocol = iota
	ProtoTLS
	ProtoHTTP
	ProtoHTTPS
)

func GetProtocolFromStr

func GetProtocolFromStr(proto string) Protocol

type Server

type Server interface {
	Start()
	StartController()
}

type ServerConfig

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

type ServerHTTP

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

func NewHTTPServer

func NewHTTPServer(cfg *ServerConfig) (*ServerHTTP, error)

func (*ServerHTTP) Start

func (srv *ServerHTTP) Start()

func (*ServerHTTP) StartController

func (srv *ServerHTTP) StartController()

StartController will do nothing in HTTP/S servers (only TCP).

type ServerTCP

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

func NewTCPServer

func NewTCPServer(cfg *ServerConfig) (*ServerTCP, error)

func (*ServerTCP) ControllerWaiter

func (srv *ServerTCP) ControllerWaiter(t time.Duration)

ControllerWaiter wait in seconds

func (*ServerTCP) ServerPortIsOpen

func (srv *ServerTCP) ServerPortIsOpen() bool

ServerPortIsOpen checks whether the TCP port is Opened, and return a boolean. True when the TCP Port is opened.

func (*ServerTCP) Start

func (srv *ServerTCP) Start()

Start is responsible to setup the TCP server, listen, and accept new connections routing the connections to the handler with non-blocking allowing parallel connections.

func (*ServerTCP) StartController

func (srv *ServerTCP) StartController()

StartController is a infinity loop to watch the Health Check Controller and force the server to not answer TCP requests when the health check should be in failing state.

func (*ServerTCP) Stop

func (srv *ServerTCP) Stop()

Jump to

Keyboard shortcuts

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