docker: Index | Files | Directories

package discovery

import ""


Package Files

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


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")

func Generate Uses

func Generate(pattern string) []string

Generate takes care of IP generation

func ParseAdvertise Uses

func ParseAdvertise(advertise string) (string, error)

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

func Register Uses

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.

type Backend Uses

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

    // 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 Uses

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 Uses

type Entries []*Entry

Entries is a list of *Entry with some helpers.

func CreateEntries Uses

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

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

func (Entries) Contains Uses

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

Contains returns true if the Entries contain a given Entry.

func (Entries) Diff Uses

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

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

func (Entries) Equals Uses

func (e Entries) Equals(cmp Entries) bool

Equals returns true if cmp contains the same data.

type Entry Uses

type Entry struct {
    Host string
    Port string

An Entry represents a host.

func NewEntry Uses

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

NewEntry creates a new entry.

func (*Entry) Equals Uses

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

Equals returns true if cmp contains the same data.

func (*Entry) String Uses

func (e *Entry) String() string

String returns the string form of an entry.

type Watcher Uses

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.



Package discovery imports 8 packages (graph) and is imported by 1607 packages. Updated 2020-02-24. Refresh now. Tools for package owners.