httpserver

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 18 Imported by: 0

README

httpserver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallHealthGorillaMux

func InstallHealthGorillaMux(router *mux.Router)

func InstallMetricsGorillaMux

func InstallMetricsGorillaMux(router *mux.Router)

func InstallMetricsRoutes

func InstallMetricsRoutes(router *http.ServeMux) error

func ListenAndServe

func ListenAndServe(config *ServerConfig, handler http.Handler)

Types

type HealthTracker

type HealthTracker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetHealthTracker

func GetHealthTracker() (*HealthTracker, error)

func InstallHealthRoutes

func InstallHealthRoutes(router *http.ServeMux) (*HealthTracker, error)

func (*HealthTracker) GetAlive

func (h *HealthTracker) GetAlive() bool

func (*HealthTracker) GetReady

func (h *HealthTracker) GetReady() bool

func (*HealthTracker) HandleHealthy

func (h *HealthTracker) HandleHealthy(w http.ResponseWriter, r *http.Request)

func (*HealthTracker) HandleLiveness

func (h *HealthTracker) HandleLiveness(w http.ResponseWriter, r *http.Request)

func (*HealthTracker) HandleReadiness

func (h *HealthTracker) HandleReadiness(w http.ResponseWriter, r *http.Request)

func (*HealthTracker) IsInit

func (h *HealthTracker) IsInit() bool

func (*HealthTracker) LogStatusMsg

func (h *HealthTracker) LogStatusMsg(msg string)

func (*HealthTracker) SetAlive

func (h *HealthTracker) SetAlive(alive bool) error

func (*HealthTracker) SetReady

func (h *HealthTracker) SetReady(ready bool) error

type ServerConfig

type ServerConfig struct {
	// Host is the local machine IP Address to bind the HTTP Server to
	Host string `yaml:"host"`

	// Port is the local machine TCP Port to bind the HTTP Server to
	Port    string        `yaml:"port"`
	Timeout TimeoutConfig `yaml:"timeout"`
}

func NewServerConfigDefault

func NewServerConfigDefault() ServerConfig

func RegisterFlagsConfig

func RegisterFlagsConfig(prefix string) *ServerConfig

type TimeoutConfig

type TimeoutConfig struct {
	// Readiness drain timeout
	Drain time.Duration `yaml:"drain"`

	// Server is the general server timeout to use
	// for graceful shutdowns
	Server time.Duration `yaml:"server"`

	// Write is the amount of time to wait until an HTTP server
	// write opperation is cancelled
	Write time.Duration `yaml:"write"`

	// Read is the amount of time to wait until an HTTP server
	// read operation is cancelled
	Read time.Duration `yaml:"read"`

	// Read is the amount of time to wait
	// until an IDLE HTTP session is closed
	Idle time.Duration `yaml:"idle"`
}

func NewTimeoutConfigDefault

func NewTimeoutConfigDefault() TimeoutConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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