github.com/afbjorklund/moby@v20.10.5+incompatible/pkg/discovery/discovery.go (about)

     1  package discovery // import "github.com/docker/docker/pkg/discovery"
     2  
     3  import (
     4  	"errors"
     5  	"time"
     6  )
     7  
     8  var (
     9  	// ErrNotSupported is returned when a discovery service is not supported.
    10  	ErrNotSupported = errors.New("discovery service not supported")
    11  
    12  	// ErrNotImplemented is returned when discovery feature is not implemented
    13  	// by discovery backend.
    14  	ErrNotImplemented = errors.New("not implemented in this discovery service")
    15  )
    16  
    17  // Watcher provides watching over a cluster for nodes joining and leaving.
    18  type Watcher interface {
    19  	// Watch the discovery for entry changes.
    20  	// Returns a channel that will receive changes or an error.
    21  	// Providing a non-nil stopCh can be used to stop watching.
    22  	Watch(stopCh <-chan struct{}) (<-chan Entries, <-chan error)
    23  }
    24  
    25  // Backend is implemented by discovery backends which manage cluster entries.
    26  type Backend interface {
    27  	// Watcher must be provided by every backend.
    28  	Watcher
    29  
    30  	// Initialize the discovery with URIs, a heartbeat, a ttl and optional settings.
    31  	Initialize(string, time.Duration, time.Duration, map[string]string) error
    32  
    33  	// Register to the discovery.
    34  	Register(string) error
    35  }