Documentation ¶
Overview ¶
Package cluster defines and implements types related to service discovery clustering.
Index ¶
Constants ¶
View Source
const ( DefaultBackendType = FilesystemBackend DefaultDirectory = "/tmp/sd-cluster" DefaultTTL = time.Duration(30) * time.Second DefaultRenewInterval = time.Duration(7) * time.Second DefaultScanInterval = time.Duration(5) * time.Second DefaultSize = 0 )
Default values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendType ¶
type BackendType int
BackendType defines the type of backend used for the cluster
const ( UnspecifiedBackend BackendType = iota // Zero-value FilesystemBackend MemoryBackend )
Available backend types
type Cluster ¶
type Cluster interface { Registrator(m Member) Registrator Membership() Membership }
Cluster represents a collection of service discovery servers ("members").
type Config ¶
type Config struct { BackendType BackendType Directory string TTL time.Duration RenewInterval time.Duration ScanInterval time.Duration Size int }
Config encapsulates cluster configuration parameters
type Listener ¶
type Listener interface { // Invoked when a member joins a cluster. OnJoin(m Member) // Invoked when a member leaves a cluster. OnLeave(m Member) }
Listener receives callbacks upon cluster membership changes.
type Member ¶
type Member interface { // ID returns The ID of the member node ID() MemberID // IP returns the IP address of the member node IP() net.IP // Port returns the replication port number of the member node Port() uint16 }
Member represents a member node in a cluster
type Membership ¶
type Membership interface { // Returns the current set of member nodes of the cluster. Members() map[Member]struct{} // Registers a listener to receive continuous callbacks upon cluster membership changes. RegisterListener(l Listener) // Unregisters a listener from receiving further callbacks upon cluster membership changes. DeregisterListener(l Listener) }
Membership provides access to the current set of members of the cluster.
type Registrator ¶
type Registrator interface { // Self returns the associated member node. Self() Member // Join adds the associated member node to the cluster. // Returns a non-nil error if and only if the member node could not be added to the cluster. Join() error // Leave removes the associated member node from the cluster. // Returns a non-nil error if and only if the member node could not be removed from the cluster. Leave() error }
Registrator enables a member node to join and leave the cluster
Click to show internal directories.
Click to hide internal directories.