config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config contains the Iaido configuration format.

Index

Constants

This section is empty.

Variables

View Source
var Resolver = net.Resolver{PreferGo: true}

Resolver can be overridden for testing.

Functions

func Bootstrap added in v0.1.4

func Bootstrap(cfg *Config, cfgPath string, bootAddr string, binds []string) error

Bootstrap will create a minimal configuration with sane defaults.

If cfgPath is non-empty, the configuration will be written to this path.

func DecodeConfig added in v0.1.2

func DecodeConfig(reader io.Reader, cfg *Config) error

DecodeConfig parses and validates a serialized YAML representation of a Config.

Types

type BackendPool

type BackendPool struct {
	// LatencyBucket allows backends to be assigned to tiers
	// automatically. Backends are grouped such that the latencies of
	// the fastest and slowest entries in a tier are no greater than the
	// given value.
	//
	// Automatic latency detection can be disabled by setting this to a
	// negative value.
	LatencyBucket time.Duration `yaml:"latencyBucket"`
	// How often connections within the pool should be evaluated for
	// over-load conditions, promotion to a higher tier, etc.
	// Longer values provide better damping of behavior, at the cost
	// of simply taking more time to effect configuration changes.
	MaintenanceTime time.Duration `yaml:"maintenanceTime"`
	// Backends are arranged in tiers with a "fill and spill" behavior.
	Tiers []Tier `yaml:"tiers"`
}

BackendPool represents the actual machines to connect to.

func (*BackendPool) Validate

func (b *BackendPool) Validate() error

Validate checks the value.

type Config

type Config struct {
	// A local address to bind a diagnostic HTTP endpoint to.
	DiagAddr    string        `yaml:"diagAddr"`
	Frontends   []Frontend    `yaml:"frontends"`
	GracePeriod time.Duration `yaml:"gracePeriod"`
}

Config is the top-level YAML-compatible configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the value.

type Frontend

type Frontend struct {
	BackendPool BackendPool `yaml:"backendPool"`
	// The local address to listen for incoming connections on.
	BindAddress string `yaml:"bindAddress"`
	// The time after which an idle connection should be pruned.
	IdleDuration time.Duration `yaml:"idleDuration"`
	// How often to rebalance backends across tiers.
	RebalanceDuration time.Duration `yaml:"rebalanceDuration"`
}

Frontend represents an active proxy frontend.

func (*Frontend) Validate

func (f *Frontend) Validate() error

Validate checks the value.

type Proto

type Proto int

Proto defines an enumeration of network protocols.

TODO(bob): Expand this to include HTTP and PSQL options.

const (
	// TCP is Transmission Control Protocol.
	TCP Proto = iota
	// UDP is User Datagram Protocol.
	UDP
)

func (Proto) MarshalText

func (p Proto) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler and returns the enum name.

func (Proto) String

func (p Proto) String() string

func (*Proto) UnmarshalText

func (p *Proto) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextMarshaler.

type Target

type Target struct {
	Disabled bool
	Hosts    []string
	Port     int
	Proto    Proto
}

A Target is a string value that can be resolved to one or more network addresses.

Targets are generally assumed to represent TCP/IP endpoints.

func ParseTarget

func ParseTarget(target string) (Target, error)

ParseTarget parses a human-provided description of a target. It should be of the form "host:port" with an optional protocol.

func (Target) Resolve

func (t Target) Resolve(ctx context.Context) ([]net.Addr, error)

Resolve performs network name resolution.

func (Target) String

func (t Target) String() string

func (*Target) Validate

func (t *Target) Validate() error

Validate checks the value.

type Tier

type Tier struct {
	// How long to disable a backend if a connection cannot be established.
	DialFailureTimeout time.Duration `yaml:"dialFailureTimeout"`
	// If non-zero, connections to this tier will be forcefully
	// disconnected if a backend in a closer tier becomes available.
	ForcePromotionAfter time.Duration `yaml:"forcePromotionAfter"`
	// The maximum number of connections to make to any given backend.
	MaxBackendConnections int      `yaml:"maxBackendConnections"`
	Targets               []Target `yaml:"targets"`
}

Tier contains the targets that the frontend will forward connections to.

func (*Tier) Validate

func (t *Tier) Validate() error

Validate checks the value.

Jump to

Keyboard shortcuts

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