{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package discovery\n\n## Variables\n\n```go\nvar (\n\t// ErrNotSupported is returned when a discovery service is not supported.\n\tErrNotSupported = errors.New(\"discovery service not supported\")\n\n\t// ErrNotImplemented is returned when discovery feature is not implemented\n\t// by discovery backend.\n\tErrNotImplemented = errors.New(\"not implemented in this discovery service\")\n)\n```\n\n## Functions\n\n```go\nfunc Generate(pattern string) []string\n```\nGenerate takes care of IP generation\n\n```go\nfunc ParseAdvertise(advertise string) (string, error)\n```\nParseAdvertise parses the --cluster-advertise daemon config which accepts \\\u003cip-address\u003e:\\\u003cport\u003e or \\\u003cinterface-name\u003e:\\\u003cport\u003e\n\n```go\nfunc Register(scheme string, d Backend) error\n```\nRegister makes a discovery backend available by the provided scheme. If Register is called twice with the same scheme an error is returned.\n\n## Types\n\n```go\ntype Backend interface {\n\t// Watcher must be provided by every backend.\n\tWatcher\n\n\t// Initialize the discovery with URIs, a heartbeat, a ttl and optional settings.\n\tInitialize(string, time.Duration, time.Duration, map[string]string) error\n\n\t// Register to the discovery.\n\tRegister(string) error\n}\n```\nBackend is implemented by discovery backends which manage cluster entries.\n\n```go\nfunc New(rawurl string, heartbeat time.Duration, ttl time.Duration, clusterOpts map[string]string) (Backend, error)\n```\nNew returns a new Discovery given a URL, heartbeat and ttl settings. Returns an error if the URL scheme is not supported.\n\n```go\ntype Entries []*Entry\n```\nEntries is a list of \\*Entry with some helpers.\n\n```go\nfunc CreateEntries(addrs []string) (Entries, error)\n```\nCreateEntries returns an array of entries based on the given addresses.\n\n```go\nfunc (e Entries) Contains(entry *Entry) bool\n```\nContains returns true if the Entries contain a given Entry.\n\n```go\nfunc (e Entries) Diff(cmp Entries) (Entries, Entries)\n```\nDiff compares two entries and returns the added and removed entries.\n\n```go\nfunc (e Entries) Equals(cmp Entries) bool\n```\nEquals returns true if cmp contains the same data.\n\n```go\ntype Entry struct {\n\tHost string\n\tPort string\n}\n```\nAn Entry represents a host.\n\n```go\nfunc NewEntry(url string) (*Entry, error)\n```\nNewEntry creates a new entry.\n\n```go\nfunc (e *Entry) Equals(cmp *Entry) bool\n```\nEquals returns true if cmp contains the same data.\n\n```go\nfunc (e *Entry) String() string\n```\nString returns the string form of an entry.\n\n```go\ntype Watcher interface {\n\t// Watch the discovery for entry changes.\n\t// Returns a channel that will receive changes or an error.\n\t// Providing a non-nil stopCh can be used to stop watching.\n\tWatch(stopCh \u003c-chan struct{}) (\u003c-chan Entries, \u003c-chan error)\n}\n```\nWatcher provides watching over a cluster for nodes joining and leaving.\n\n","path":"github.com/hyperhq/hypercli/pkg/discovery","name":"discovery","synopsis":"","isRedistributable":true}
