server

package
v0.0.0-...-b09f343 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: BSD-3-Clause, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main() int

Main configures and starts a server with specified configuration, file system, and aws service clients. Returns int representing shutdown status.

Types

type Opt

type Opt func(s *Server) (*Server, error)

Opt is the signature of server configuration functions

func WithHandlers

func WithHandlers(routes map[string]http.HandlerFunc, isProd bool) Opt

WithHandlers loads HTTP handlers on endpoints

type Server

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

Server w/ embedded *http.Server, *mux.Router, zerolog.Logger instances. Manages configurations, starting, stopping and routing of server instances

func New

func New(c *config.Config, opts ...Opt) (*Server, error)

New configures and returns a server instance struct with the specified opts

func (*Server) AcceptConnections

func (s *Server) AcceptConnections() error

AcceptConnections listens on the configured address and ports for http traffic. Simultaneously listens for incoming os signals, will return on either a server error or a shutdown signal

func (*Server) GetLivenessCheck

func (s *Server) GetLivenessCheck() (time.Duration, error)

GetLivenessCheck retrieves the liveness check interval from systemd if running in production mode (i.e., with systemd), else the interval specified in the configuration

func (*Server) LivenessCheck

func (s *Server) LivenessCheck(interval time.Duration)

LivenessCheck retrieves home page to verify the liveness of the server, then notifies the systemd daemon to pass the check. systemd will restart server on failed health check

func (*Server) OpenListener

func (s *Server) OpenListener() (net.Listener, error)

OpenListener returns a listener for the server to receive traffic on, or err Will prefer using a systemd activated socket if `LISTEN_PID` defined in env

Jump to

Keyboard shortcuts

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