Documentation
¶
Index ¶
- Constants
- func Intersection(nodes []db.NodeInfo, services []db.ServiceNodeInfo) (map[string]NodeData, map[string]NodeData)
- func ParsePeerType(t string) (members.PeerType, error)
- type Cluster
- type Daemon
- type Discovery
- type Endpoints
- type EventBus
- type Gateway
- type Member
- type MemberList
- type Members
- type Node
- type NodeData
- type Option
- type Peer
- func (p *Peer) AddHandler(handler members.Handler)
- func (p *Peer) Address() string
- func (p *Peer) Close()
- func (p *Peer) ClusterSize() int
- func (p *Peer) Current(peerType members.PeerType, includeLocal bool) (res []string, err error)
- func (p *Peer) DispatchEvent(e members.Event) error
- func (p *Peer) Join() (int, error)
- func (p *Peer) Leave() error
- func (p *Peer) Name() string
- func (p *Peer) RemoveHandler(handler members.Handler)
- func (p *Peer) State() map[string]interface{}
Constants ¶
const Interval = 10
Interval represents the number of seconds to wait between each schedule iteration
const ( // PeerTypeStore serves the store API PeerTypeStore members.PeerType = "store" )
Variables ¶
This section is empty.
Functions ¶
func Intersection ¶
func Intersection(nodes []db.NodeInfo, services []db.ServiceNodeInfo) (map[string]NodeData, map[string]NodeData)
Intersection checks to see if there are any nodes and services that need to be added or removed.
Types ¶
type Cluster ¶
type Cluster interface { database.DBAccessor db.ClusterOpener db.ClusterTransactioner db.ClusterExclusiveLocker // NodeID sets the the node NodeID associated with this cluster instance. It's used for // backward-compatibility of all db-related APIs that were written before // clustering and don't accept a node NodeID, so in those cases we automatically // use this value as implicit node NodeID. NodeID(int64) // SchemaVersion returns the underlying schema version for the cluster SchemaVersion() int // Close the database facade. Close() error }
Cluster mediates access to data stored in the cluster dqlite database.
type Daemon ¶
type Daemon interface { // Gateway returns the underlying Daemon Gateway Gateway() Gateway // Cluster returns the underlying Cluster Cluster() Cluster // Node returns the underlying Node associated with the daemon Node() Node // NodeConfigSchema returns the daemon schema for the local Node NodeConfigSchema() config.Schema // Endpoints returns the underlying endpoints that the daemon controls. Endpoints() Endpoints }
Daemon can respond to requests from a shared client.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery represents a task collection of things that want to be run
type Endpoints ¶
type Endpoints interface { // NetworkPrivateKey returns the private key of the TLS certificate used by the // network endpoint. NetworkPrivateKey() []byte // NetworkPublicKey returns the public key of the TLS certificate used by the // network endpoint. NetworkPublicKey() []byte }
Endpoints are in charge of bringing up and down the HTTP endpoints for serving the RESTful API.
type EventBus ¶
type EventBus interface { // AddHandler attaches a event listener to all the members events // and broadcasts the event to the handler. AddHandler(members.Handler) // RemoveHandler removes the event listener. RemoveHandler(members.Handler) // DispatchEvent dispatches an event to all the members in the cluster. DispatchEvent(members.Event) error }
EventBus allows the distributing and receiving of events over the cluster
type Gateway ¶
type Gateway interface { // IsDatabaseNode returns true if this gateway also run acts a raft database // node. IsDatabaseNode() bool // LeaderAddress returns the address of the current raft leader. LeaderAddress() (string, error) }
Gateway mediates access to the dqlite cluster using a gRPC SQL client, and possibly runs a dqlite replica on this node (if we're configured to do so).
type Member ¶
type Member interface { // Name returns the name of the member Name() string // Address returns the host:port of the member Address() string }
Member represents a node in the cluster.
type MemberList ¶
type MemberList interface { // NumMembers returns the number of alive nodes currently known. Between // the time of calling this and calling Members, the number of alive nodes // may have changed, so this shouldn't be used to determine how many // members will be returned by Members. NumMembers() int // LocalNode is used to return the local Member LocalNode() Member // Members returns a point-in-time snapshot of the members of this cluster. Members() []Member }
MemberList represents a way to manage members with in a cluster
type Members ¶
type Members interface { EventBus // Join joins an existing members cluster. Returns the number of nodes // successfully contacted. The returned error will be non-nil only in the // case that no nodes could be contacted. Join() (int, error) // Leave gracefully exits the cluster. It is safe to call this multiple // times. Leave() error // Memberlist is used to get access to the underlying Memberlist instance MemberList() MemberList // Walk over a set of alive members Walk(func(members.PeerInfo) error) error // Shutdown the current members cluster Shutdown() error }
Members represents a way of joining a members cluster
type Node ¶
type Node interface { database.DBAccessor db.NodeOpener db.NodeTransactioner // Dir returns the directory of the underlying database file. Dir() string // Close the database facade. Close() error }
Node mediates access to the data stored locally
type Option ¶
type Option func(*options)
Option to be passed to Connect to customize the resulting instance.
func WithLogger ¶
WithLogger sets the logger on the option
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents the node with in the cluster.
func NewPeer ¶
NewPeer creates or joins a cluster with the existing peers. We will listen for cluster communications on the bind addr:port. We advertise a PeerType HTTP API, reachable on apiPort.
func (*Peer) AddHandler ¶
AddHandler attaches an event listener to all the members events and broadcasts the event to the handler.
func (*Peer) ClusterSize ¶
ClusterSize returns the total size of the cluster from this node's perspective.
func (*Peer) Current ¶
Current API host:ports for the given type of node. IncludeLocal doesn't add the local cluster node to the resulting set.
func (*Peer) DispatchEvent ¶
DispatchEvent dispatches an event to all the members in the cluster.
func (*Peer) RemoveHandler ¶
RemoveHandler removes the event listener.