haproxy

package
v3.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackendServerStateReady indicates a server is ready.
	BackendServerStateReady BackendServerState = "ready"

	// BackendServerStateDrain indicates a server is ready but draining.
	BackendServerStateDrain BackendServerState = "drain"

	// BackendServerStateDown indicates a server is down.
	BackendServerStateDown BackendServerState = "down"

	// BackendServerStateMaint indicates a server is under maintainence.
	BackendServerStateMaint BackendServerState = "maint"

	// ListBackendsCommand is the command to get a list of all backends.
	ListBackendsCommand = "show backend"

	// GetServersStateCommand gets the state of all servers. This can be
	// optionally filtered by backends by passing a backend name.
	GetServersStateCommand = "show servers state"

	// SetServerCommand sets server specific information and state.
	SetServerCommand = "set server"
)

Variables

This section is empty.

Functions

func NewHAProxyConfigManager

func NewHAProxyConfigManager(options templaterouter.ConfigManagerOptions) *haproxyConfigManager

NewHAProxyConfigManager returns a new haproxyConfigManager.

Types

type Backend

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

Backend represents a specific haproxy backend.

func (*Backend) Commit

func (b *Backend) Commit() error

Commit commits all the pending changes made to a haproxy backend.

func (*Backend) Disable

func (b *Backend) Disable() error

Disable stops serving traffic for all servers for a haproxy backend.

func (*Backend) DisableServer

func (b *Backend) DisableServer(name string) error

DisableServer stops serving traffic for a haproxy backend server.

func (*Backend) EnableServer

func (b *Backend) EnableServer(name string) error

EnableServer enables serving traffic with a haproxy backend server.

func (*Backend) FindServer

func (b *Backend) FindServer(id string) (*backendServer, error)

FindServer returns a specific haproxy backend server if found.

func (*Backend) Name

func (b *Backend) Name() string

Name returns the name of this haproxy backend.

func (*Backend) Refresh

func (b *Backend) Refresh() error

Refresh refreshs our internal state for this haproxy backend.

func (*Backend) Reset

func (b *Backend) Reset()

Reset resets the cached server info in this haproxy backend.

func (*Backend) Servers

func (b *Backend) Servers() ([]BackendServerInfo, error)

Servers returns the servers for this haproxy backend.

func (*Backend) SetRoutingKey

func (b *Backend) SetRoutingKey(k string) error

SetRoutingKey sets the cookie routing key for the haproxy backend.

func (*Backend) UpdateServerInfo

func (b *Backend) UpdateServerInfo(id, ipaddr, port string, weight int32, relativeWeight bool) error

UpdateServerInfo updates the information for a haproxy backend server.

func (*Backend) UpdateServerState

func (b *Backend) UpdateServerState(id string, state BackendServerState) error

UpdateServerState specifies what should be the state of a haproxy backend server when all the changes made to the backend committed.

type BackendServerInfo

type BackendServerInfo struct {
	Name          string
	FQDN          string
	IPAddress     string
	Port          int
	CurrentWeight int32
	InitialWeight int32
	State         BackendServerState
}

BackendServerInfo represents a server [endpoint] for a haproxy backend.

type BackendServerState

type BackendServerState string

BackendServerState indicates the state for a haproxy backend server.

type BlueprintPlugin

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

BlueprintPlugin implements the router.Plugin interface to process routes from the blueprint namespace for the associated config manager.

func NewBlueprintPlugin

func NewBlueprintPlugin(cm templaterouter.ConfigManager) *BlueprintPlugin

NewBlueprintPlugin returns a new blueprint routes plugin.

func (*BlueprintPlugin) Commit

func (p *BlueprintPlugin) Commit() error

Commit commits the changes made to a watched resource.

func (*BlueprintPlugin) HandleEndpoints

func (p *BlueprintPlugin) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error

HandleEndpoints processes watch events on the Endpoints resource.

func (*BlueprintPlugin) HandleNamespaces

func (p *BlueprintPlugin) HandleNamespaces(namespaces sets.String) error

HandleNamespaces processes watch events on namespaces.

func (*BlueprintPlugin) HandleNode

func (p *BlueprintPlugin) HandleNode(eventType watch.EventType, node *kapi.Node) error

HandleNode processes watch events on the Node resource.

func (*BlueprintPlugin) HandleRoute

func (p *BlueprintPlugin) HandleRoute(eventType watch.EventType, route *routev1.Route) error

HandleRoute processes watch events on blueprint routes.

type ByteConverterFunc

type ByteConverterFunc func([]byte) ([]byte, error)

ByteConverterFunc converts bytes!

type CSVConverter

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

CSVConverter is used to convert the haproxy dynamic configuration API responses into something that is valid CSV and then parse the response and unmarshal it into native golang structs.

func NewCSVConverter

func NewCSVConverter(headers string, out interface{}, fn ByteConverterFunc) *CSVConverter

NewCSVConverter returns a new CSVConverter.

func (*CSVConverter) Convert

func (c *CSVConverter) Convert(data []byte) ([]byte, error)

Convert runs a haproxy dynamic config API command.

type Client

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

Client is a client used to dynamically configure haproxy.

func NewClient

func NewClient(socketName string, timeout int) *Client

NewClient returns a client used to dynamically change the haproxy config.

func (*Client) Backends

func (c *Client) Backends() ([]*Backend, error)

Backends returns the list of configured haproxy backends.

func (*Client) Commit

func (c *Client) Commit() error

Commit flushes out any pending changes on all the backends and maps.

func (*Client) Execute

func (c *Client) Execute(cmd string) ([]byte, error)

Execute runs a haproxy dynamic config API command.

func (*Client) FindBackend

func (c *Client) FindBackend(id string) (*Backend, error)

FindBackend returns a specific haproxy backend if it is configured.

func (*Client) FindMap

func (c *Client) FindMap(name string) (*HAProxyMap, error)

FindMap returns a populated haproxy map.

func (*Client) Maps

func (c *Client) Maps() ([]*HAProxyMap, error)

Maps returns the list of configured haproxy maps.

func (*Client) Reset

func (c *Client) Reset()

Reset resets any changes and clears the backends and maps.

func (*Client) RunCommand

func (c *Client) RunCommand(cmd string, converter Converter) ([]byte, error)

RunCommand executes a haproxy dynamic config API command and if present converts the response as desired.

type Converter

type Converter interface {
	// Convert converts a set of bytes.
	Convert(data []byte) ([]byte, error)
}

Converter transforms a set of bytes. The haproxy dynamic API command responses are not always csv/compliant. This allows us to inject custom converters to make the responses valid csv and parseable.

type HAProxyMap

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

HAProxyMap is a structure representing an haproxy map.

func (*HAProxyMap) Add

func (m *HAProxyMap) Add(k, v string, replace bool) error

Add adds a new key and value to the haproxy map and allows all previous entries in the map to be deleted (replaced).

func (*HAProxyMap) Commit

func (m *HAProxyMap) Commit() error

Commit commits all the pending changes made to this haproxy map. We do map changes "in-band" as that's handled dynamically by haproxy.

func (*HAProxyMap) Delete

func (m *HAProxyMap) Delete(k string) error

Delete removes all the matching keys from the haproxy map.

func (*HAProxyMap) DeleteEntry

func (m *HAProxyMap) DeleteEntry(id string) error

DeleteEntry removes a specific haproxy map entry.

func (*HAProxyMap) Find

func (m *HAProxyMap) Find(k string) ([]HAProxyMapEntry, error)

Find returns a list of matching entries in the haproxy map.

func (*HAProxyMap) Name

func (m *HAProxyMap) Name() string

Name returns the name of this map.

func (*HAProxyMap) Refresh

func (m *HAProxyMap) Refresh() error

Refresh refreshes the data in this haproxy map.

type HAProxyMapEntry

type HAProxyMapEntry struct {
	// ID is the internal haproxy id associated with this map entry.
	// It is required for deleting map entries.
	ID string `csv:"id"`

	// Name is the entry key.
	Name string `csv:"name"`

	// Value is the entry value.
	Value string `csv:"value"`
}

HAPrroxyMapEntry is an entry in HAProxyMap.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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