package discovery

import "github.com/docker/cli/components/engine/pkg/discovery"

Index

Variables

var (
	// ErrNotSupported is returned when a discovery service is not supported.
	ErrNotSupported = errors.New("discovery service not supported")

	// ErrNotImplemented is returned when discovery feature is not implemented
	// by discovery backend.
	ErrNotImplemented = errors.New("not implemented in this discovery service")
)

Functions

func Generate

func Generate(pattern string) []string

Generate takes care of IP generation

func ParseAdvertise

func ParseAdvertise(advertise string) (string, error)

ParseAdvertise parses the --cluster-advertise daemon config which accepts <ip-address>:<port> or <interface-name>:<port>

func Register

func Register(scheme string, d Backend) error

Register makes a discovery backend available by the provided scheme. If Register is called twice with the same scheme an error is returned.

Types

type Backend

type Backend interface {
	// Watcher must be provided by every backend.
	Watcher

	// Initialize the discovery with URIs, a heartbeat, a ttl and optional settings.
	Initialize(string, time.Duration, time.Duration, map[string]string) error

	// Register to the discovery.
	Register(string) error
}

Backend is implemented by discovery backends which manage cluster entries.

func New

func New(rawurl string, heartbeat time.Duration, ttl time.Duration, clusterOpts map[string]string) (Backend, error)

New returns a new Discovery given a URL, heartbeat and ttl settings. Returns an error if the URL scheme is not supported.

type Entries

type Entries []*Entry

Entries is a list of *Entry with some helpers.

func CreateEntries

func CreateEntries(addrs []string) (Entries, error)

CreateEntries returns an array of entries based on the given addresses.

func (Entries) Contains

func (e Entries) Contains(entry *Entry) bool

Contains returns true if the Entries contain a given Entry.

func (Entries) Diff

func (e Entries) Diff(cmp Entries) (Entries, Entries)

Diff compares two entries and returns the added and removed entries.

func (Entries) Equals

func (e Entries) Equals(cmp Entries) bool

Equals returns true if cmp contains the same data.

type Entry

type Entry struct {
	Host string
	Port string
}

An Entry represents a host.

func NewEntry

func NewEntry(url string) (*Entry, error)

NewEntry creates a new entry.

func (*Entry) Equals

func (e *Entry) Equals(cmp *Entry) bool

Equals returns true if cmp contains the same data.

func (*Entry) String

func (e *Entry) String() string

String returns the string form of an entry.

type Watcher

type Watcher interface {
	// Watch the discovery for entry changes.
	// Returns a channel that will receive changes or an error.
	// Providing a non-nil stopCh can be used to stop watching.
	Watch(stopCh <-chan struct{}) (<-chan Entries, <-chan error)
}

Watcher provides watching over a cluster for nodes joining and leaving.

Source Files

backends.go discovery.go entry.go generator.go

Directories

PathSynopsis
components/engine/pkg/discovery/file
components/engine/pkg/discovery/kv
components/engine/pkg/discovery/memory
components/engine/pkg/discovery/nodes
Version
v17.10.0-ce-rc1+incompatible
Published
Oct 4, 2017
Platform
linux/amd64
Imports
8 packages
Last checked
26 minutes ago

Tools for package owners.