slb

package
v0.0.0-...-3be6b84 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPHash           = "ip-hash"
	RoundRobin       = "round-robin"
	LeastConnections = "least-connections"
)

Represents name of balancing algorithm.

Variables

This section is empty.

Functions

func Load

func Load(path string, cfg *Config) error

Load loads configuration content of the given the path.

func WithBalancingHandlerDirector

func WithBalancingHandlerDirector(d HandlerDirector) func(*serverLoadBalancer)

WithBalancingHandlerDirector returns an Option that sets the Balancer.Handler implementation.

Types

type Balancing

type Balancing string

Balancing is custom type for balancing algorithm name.

func (Balancing) CreateHandler

func (b Balancing) CreateHandler(urls []*url.URL, proxier balancer.Proxier) balancer.Handler

CreateHandler returns balancer.Handler implementation. If set invalid balancing algorithm, returns the default balancing algorithm(round-robin).

type Config

type Config struct {
	Host                 string `yaml:"host"`
	Port                 string `yaml:"port"`
	TLSConfig            `yaml:"tls"`
	Balancing            Balancing     `yaml:"balancing"`
	BackendServerConfigs ServerConfigs `yaml:"servers"`
}

Config represents an application configuration content (config.yaml).

type HandlerDirector

type HandlerDirector func(urls []*url.URL, proxier balancer.Proxier) balancer.Handler

HandlerDirector type is director to generate handler.Handler implementation.

type Option

type Option func(*serverLoadBalancer)

Option configures serverLoadBalancer.

type Server

type Server interface {
	ListenAndServe() error
	Shutdown(context.Context) error
}

Server is an interface for representing server load balancer implementation.

func CreateSLB

func CreateSLB(cfg *Config, ops ...Option) (Server, error)

CreateSLB returns Server implementation(*serverLoadBalancer) from the given Config.

type ServerConfig

type ServerConfig struct {
	Scheme string `yaml:"scheme"`
	Host   string `yaml:"host"`
	Port   string `yaml:"port"`
	// contains filtered or unexported fields
}

ServerConfig represents configuration content for server.

func (ServerConfig) String

func (sc ServerConfig) String() string

type ServerConfigs

type ServerConfigs []ServerConfig

ServerConfigs represents ServerConfig slice.

type TLSConfig

type TLSConfig struct {
	// Enable represents the server load balancer enable TLS or not.
	Enabled bool `yaml:"enabled"`

	// CertKey represents the environment variable name having the certificate file path of server load balancer.
	CertKey string `yaml:"cert_key"`

	// KeyKey represents the environment variable name having the private key file path of server load balancer certificate.
	KeyKey string `yaml:"key_key"`
}

TLSConfig represents the TLS configuration for server load balancer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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