config

package
v0.0.0-...-8980779 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2016 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const ServiceBackendWeight uint = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Routes   map[string]Route
	Services map[string]Service
}

Top-level config object

type EtcdOptions

type EtcdOptions struct {
	Scheme string        `long:"etcd-scheme" value-name:"http|https" default:"http" description:"Set default scheme for etcd:// URLs"`
	Hosts  []string      `long:"etcd-host" value-name:"HOST:PORT" description:"Include hosts"`
	Prefix string        `long:"etcd-prefix" value-name:"/PATH" default:"/clusterf" description:"Namespace all keys under given path"`
	TTL    time.Duration `long:"etcd-ttl" value-name:"DURATION" default:"10s" description:"Write values with given TTL, and refresh at half of that"`
	// contains filtered or unexported fields
}

func (EtcdOptions) Open

func (options EtcdOptions) Open() (*EtcdSource, error)

func (EtcdOptions) OpenURL

func (options EtcdOptions) OpenURL(url *url.URL) (*EtcdSource, error)

func (EtcdOptions) String

func (options EtcdOptions) String() string

type EtcdSource

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

func (*EtcdSource) Flush

func (etcd *EtcdSource) Flush() (err error)

Remove all published nodes

func (*EtcdSource) Init

func (etcd *EtcdSource) Init() error

* Initialize state in etcd. * * Creates the top-level config directory if it does not exist, and initialize to follow it

func (*EtcdSource) Scan

func (etcd *EtcdSource) Scan() ([]Node, error)

* Synchronize current state in etcd. * * Does a recursive get on the complete /clusterf tree in etcd, and builds the services state from it. * * Stores the current etcd-index from the snapshot in .syncIndex, so that .Sync() can be used to continue updating any changes.

func (*EtcdSource) String

func (etcd *EtcdSource) String() string

func (*EtcdSource) Sync

func (etcd *EtcdSource) Sync(syncChan chan Node) error

* Watch for changed Nodes in etcd. * * Sends any changes on the returned channel. Closes the channel on errors.

func (*EtcdSource) Write

func (etcd *EtcdSource) Write(nodes map[string]Node) error

Publish a config into etcd. The node will be refreshed per our TTL

type FileOptions

type FileOptions struct {
	Path string
}

func (FileOptions) Open

func (options FileOptions) Open() (*FileSource, error)

type FileSource

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

func (*FileSource) Scan

func (fs *FileSource) Scan() (nodes []Node, err error)

Recursively any Config's under given path

func (*FileSource) String

func (fs *FileSource) String() string

type Meta

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

Config objects

func (Meta) Path

func (meta Meta) Path() string

func (Meta) Source

func (meta Meta) Source() string

type Node

type Node struct {
	/* Identity */
	Source Source

	// clusterf-relative path, so with any prefix and leading / stripped
	Path string

	/* Type/Value */
	IsDir bool

	// json-encoded; empty if removed
	Value  string
	Remove bool
}

Low-level config model, used to load files from local and etcd

func (Node) Equals

func (node Node) Equals(other Node) bool

func (Node) Matches

func (node Node) Matches(other Node) bool

func (Node) String

func (node Node) String() string

XXX: include source?

type Reader

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

Read and merge Configs from multiple Sources

func (*Reader) Get

func (reader *Reader) Get() Config

Get current config

func (*Reader) Listen

func (reader *Reader) Listen() chan Config

Follow config updates Closed if there are no sources to sync updates from, or on error. TODO: errors from chan close

type ReaderOptions

type ReaderOptions struct {
	SourceOptions
	SourceURLs []string `` /* 133-byte string literal not displayed */

	FilterRoutes string `long:"filter-routes" value-name:"URL-PREFIX" description:"Only apply routes from matching --config-source"`
}

func (ReaderOptions) Reader

func (options ReaderOptions) Reader() (*Reader, error)

Return a new Reader with the given config URLs opened

type Route

type Route struct {
	Meta `json:"-"`

	// IPv4/IPv6 prefix to match
	// empty for default match
	Prefix string `json:",omitempty"`

	// Override backend IPv4/IPv6 address for ipvs
	Gateway string `json:",omitempty"`

	// Configure IPVS fwd-method for destination:
	//  droute tunnel masq
	// Filter out backend if set to empty string.
	IPVSMethod string `json:",omitempty"`
}

type Service

type Service struct {
	Meta `json:"-"`

	Frontend *ServiceFrontend
	Backends map[string]ServiceBackend
}

type ServiceBackend

type ServiceBackend struct {
	Meta `json:"-"`

	IPv4 string `json:"ipv4,omitempty"`
	IPv6 string `json:"ipv6,omitempty"`
	TCP  uint16 `json:"tcp,omitempty"`
	UDP  uint16 `json:"udp,omitempty"`

	Weight uint `json:"weight"` // default: 10
}

type ServiceFrontend

type ServiceFrontend struct {
	Meta `json:"-"`

	IPv4 string `json:"ipv4,omitempty"`
	IPv6 string `json:"ipv6,omitempty"`
	TCP  uint16 `json:"tcp,omitempty"`
	UDP  uint16 `json:"udp,omitempty"`
}

type Source

type Source interface {
	// uniquely identifying
	String() string
}

A single Config may contain Nodes from different Sources

type SourceOptions

type SourceOptions struct {
	Etcd EtcdOptions `group:"Config etcd://"`
}

type Writer

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

func (*Writer) Flush

func (writer *Writer) Flush() error

Stop publishing

func (*Writer) Write

func (writer *Writer) Write(config Config) error

Publish config as nodes to our source

type WriterOptions

type WriterOptions struct {
	SourceOptions
	SourceURL string `long:"config-source" value-name:"(file|etcd|etcd+http|etcd+https)://[<host>]/<path>" description:"Write to given source"`
}

func (WriterOptions) Writer

func (options WriterOptions) Writer() (*Writer, error)

Jump to

Keyboard shortcuts

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