haproxy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewManager

func NewManager(configFile string, balancerScript string, certsDir string) (balancer.Manager, error)

NewManager returns the HAProxy balancer manager

Types

type ACL

type ACL struct {
	Name    string
	Content string
}

ACL from request

func NewHostNameACL

func NewHostNameACL(h string) *ACL

NewHostNameACL returns a host check ACL

func NewPathACL

func NewPathACL(p string) *ACL

NewPathACL returns a path check ACL

type Backend

type Backend struct {
	Servers map[string]Server
}

Backend servers group

func (*Backend) Name

func (b *Backend) Name() string

TODO delete! Name accourding to backend contents

type Bind

type Bind struct {
	IP   string
	Port int
	// TODO part away from balancer.Certs and create a struct that also holds the filename
	Certs []balancer.Certificate
}

Bind ip port and certificates

func (Bind) IsTLS

func (b Bind) IsTLS() bool

IsTLS retuns true if some certificates need to be configured for the binded port

type Certs

type Certs struct {
	Name    string
	Content string
}

Certs certificates

type Defaults

type Defaults struct {
	// running mode for HAProxy
	Mode string
	// default load balancing strategy
	Balance string
	// maximum number of connections for an upstream server
	Maxconn int
	// enables rich TCP log
	TCPLog bool
	// enables rich HTTP log
	HTTPLog bool
	// early drop of aborted requests
	AbortOnClose bool
	// enables connection close, allowing also keep-alive
	HTTPServerClose bool
	// adds X-Forwarded-For header
	ForwardFor bool
	// number of retries to servers
	Retries int
	// break affinity when the upstream server is down
	Redispatch bool
	// timeout for connections to an upstream server
	TimeoutConnect string
	// timeout for client inactivity
	TimeoutClient string
	// timeout for server inactivity
	TimeoutServer string
	// avoid logging empty data connections
	DontLogNull bool
	// timeout for health checks
	TimeoutCheck string

	// placeholder for other global parameters
	Others map[string]string
}

Defaults HAProxy section

type FrontEnd

type FrontEnd struct {
	Name           string
	Bind           Bind
	ACLs           map[string]ACL
	DefaultBackend UseBackend
	UseBackends    []UseBackend
	Opts           []string
}

FrontEnd listening and request parsing

func (FrontEnd) UseBackendsByPrio

func (fe FrontEnd) UseBackendsByPrio() []UseBackend

UseBackendsByPrio returns ordered use_backend by priority

type Global

type Global struct {
	// maximum concurrent connections
	Maxconn int
	// maximum number of pipes for kernel splicing
	Maxpipes int
	// Randomness for health checks intervals
	SpreadChecks int
	// Activate verbose logging
	Debug bool

	// placeholder for other global parameters
	Others map[string]string
}

Global HAProxy section

type HAProxy

type HAProxy struct {
	Global    Global
	Defaults  Defaults
	Frontends map[int]FrontEnd
	Backends  map[string]Backend
	CertsDir  string
}

HAProxy balancer instance

func NewDefaultBalancer

func NewDefaultBalancer() *HAProxy

NewDefaultBalancer returns an HAProxy balancer

type Manager

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

Manager is an HAProxy manager

func (*Manager) Check

func (m *Manager) Check(req *http.Request) error

Check that AHProxy is listening on frontends

func (*Manager) Name

func (m *Manager) Name() string

Name for the healtz item

func (*Manager) ReloadBalancer

func (m *Manager) ReloadBalancer() error

ReloadBalancer starts the balancer process

func (*Manager) StartBalancer

func (m *Manager) StartBalancer() error

StartBalancer starts the balancer process

func (*Manager) StopBalancer

func (m *Manager) StopBalancer() error

StopBalancer stops balancer process

func (*Manager) WriteConfigAndRestart

func (m *Manager) WriteConfigAndRestart(config *balancer.Config, force bool) error

WriteConfigAndRestart if not forced, compares argument config with cached config writes a new config and restarts balancer

type Server

type Server struct {
	Address    string
	Port       int
	CheckInter int
	Opts       []string
}

Server for backend

func NewDefaultBackendServer

func NewDefaultBackendServer() *Server

NewDefaultBackendServer returns a backend server

func (*Server) Name

func (s *Server) Name() string

Name according to Server contents

type UseBackend

type UseBackend struct {
	Priority int
	Backend  string
	ACLs     []ACL
}

UseBackend associates backends and ACLs

type UseBackends

type UseBackends []UseBackend

UseBackends holds a sortable collection of UseBackend

func (UseBackends) Len

func (u UseBackends) Len() int

Len of use_backends

func (UseBackends) Less

func (u UseBackends) Less(i, j int) bool

Less compares use_backend priotities

func (UseBackends) Swap

func (u UseBackends) Swap(i, j int)

Swap use backends

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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