cli

package
v0.0.0-...-d8c09a4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory(config Config, logger *zap.Logger) (*http_lb.Frontend, *http_lb.HealthCheck)

func FrontendFactory

func FrontendFactory(frontend Frontend, reqForwarder http_lb.RequestForwarder, logger *zap.Logger) *http_lb.Frontend

func HealthCheckFactory

func HealthCheckFactory(healthCheck HealthCheck, serverPool http_lb.ServerPool, logger *zap.Logger) *http_lb.HealthCheck

func LoadBalancingAlgorithmFactory

func LoadBalancingAlgorithmFactory(serverPool http_lb.ServerPool,
	hash http_lb.HashingAlgorithm, logger *zap.Logger) func(algorithmName string) http_lb.LoadBalancingAlgorithm

func ServerPoolFactory

func ServerPoolFactory(backendsConfig Backend, logger *zap.Logger) http_lb.ServerPool

Types

type Backend

type Backend struct {
	Servers   []string      `mapstructure:"servers" validate:"required"`
	Timeout   time.Duration `mapstructure:"timeout" validate:"min=1ms,required"`
	KeepAlive KeepAlive     `mapstructure:"keep_alive" validate:"required"`
}

type Config

type Config struct {
	Algorithm   string      `mapstructure:"algorithm" validate:"oneof=round-robin sticky-round-robin weighted-round-robin url-hash ip-hash random"`
	LogLevel    string      `mapstructure:"log_level" validate:"oneof=debug info warn error"`
	Frontend    Frontend    `mapstructure:"frontend" validate:"required"`
	Backend     Backend     `mapstructure:"backend" validate:"required"`
	HealthCheck HealthCheck `mapstructure:"health_check" validate:"required"`
}

func ParseAndValidateConfig

func ParseAndValidateConfig(configFilePath string) (Config, error)

type Frontend

type Frontend struct {
	Listen string `mapstructure:"listen" validate:"required"`
	TLS    *TLS   `mapstructure:"tls"`
}

type HealthCheck

type HealthCheck struct {
	Endpoint           string        `mapstructure:"endpoint" validate:"uri,required"`
	ExpectedStatusCode int           `mapstructure:"expected_status_code" validate:"min=100,max=599,required"`
	Interval           time.Duration `mapstructure:"interval" validate:"min=1ms,required"`
	Timeout            time.Duration `mapstructure:"timeout" validate:"min=1ms,required"`
}

type KeepAlive

type KeepAlive struct {
	MaxIdle     int           `mapstructure:"max_idle_connections" validate:"min=0,required"`
	IdleTimeout time.Duration `mapstructure:"idle_connection_timeout" validate:"min=0s,required"`
}

type TLS

type TLS struct {
	CertFile string `mapstructure:"cert" validate:"filepath,required"`
	KeyFile  string `mapstructure:"key" validate:"filepath,required"`
}

Jump to

Keyboard shortcuts

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