Documentation ¶
Overview ¶
Package cluster provides basic tools to build a self-aware cluster of applications. You can join a cluster and query peers that serve general build metadata.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
type Metadata struct { Version string `json:"version,omitempty"` ApplicationName string `json:"application_name,omitempty"` ApplicationDescription string `json:"application_description,omitempty"` Compiled time.Time `json:"compiled,omitempty"` Extra json.RawMessage `json:"extra,omitempty"` }
The Metadata type contains fields advertised by nodes in the cluster that describe themselves.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
The Node type represents the local node in the cluster.
func JoinLAN ¶
JoinLAN attempts to join a LAN-based cluster. It uses the hostname as the node name, and otherwise sets very conservative values that are sane for most LAN environments.
func JoinLocal ¶
JoinLocal attempts to join a local cluster. It works similarly to JoinLAN, however it uses a configuration that is optimized for a local loopback environments.
func JoinWAN ¶
JoinWAN attempts to join a WAN-based cluster. It uses a configuration that is optimized for most WAN environments.
type Option ¶
type Option func(cnf *config)
The Option type is a function that modifies the cluster configuration.
func WithExtraMetadata ¶ added in v1.5.0
func WithExtraMetadata(extra interface{}) Option
WithExtraMetadata sets an additional metadata value that will be advertised to all nodes in the cluster. The provided interface must allow JSON-encoding. Otherwise, this function will panic.
func WithLogger ¶
WithLogger sets the logger to be used by the discovery mechanism. By default, logging is disabled.
func WithName ¶
WithName sets the advertised name of the node, this should be unique across the cluster.
func WithNodes ¶
WithNodes sets a slice of addresses that the local node will connect to when the cluster is joined.
func WithSecretKey ¶
WithSecretKey sets the secret key to use to encrypt messages between nodes.