Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ClockDiffrent is a clock difference. ClockDiffrent = 1 // ClockMax is a maximum clock value. ClockMax = math.MaxUint64 )
View Source
const (
DefaultClusterName = "puzzledb"
)
Variables ¶
This section is empty.
Functions ¶
func CompareClocks ¶
CompareClocks compares two clocks. If c1 and c2 are equal, returns 0. If c1 is greater than c2, returns 1. If c2 is greater than c1, returns -1. However, if the difference between c1 and c2 is greater than half of the maximum UNIT64 value, the clock is considered to be back to zero and the comparison results are reversed.
Types ¶
type Cluster ¶
type Cluster interface { // Name returns a name of the cluster. Name() string // Nodes returns nodes in the cluster. Nodes() []Node }
Cluster represents a cluster.
func NewClusterWith ¶
NewClusterWith returns a new cluster with the specified name and nodes.
type Node ¶
type Node interface { // SetCluster sets a cluster name to the cluster node. SetCluster(cluster string) // Cluster returns a cluster name of the cluster node. Cluster() string // SetID sets a UUID to the cluster node. SetID(uuid uuid.UUID) // ID returns a UUID of the cluster node. ID() uuid.UUID // SetHost sets a host name to the cluster node. SetHost(host string) // Host returns a host name of the cluster node. Host() string // SetClock sets a logical clock to the cluster node. SetClock(clock Clock) // Clock returns a logical clock of the cluster node. Clock() Clock // SetReceivedClock sets a received logical clock to the cluster node. SetReceivedClock(clock Clock) Clock // IncrementClock increments a logical clock of the cluster node. IncrementClock() Clock // SetTimestamp sets a phisical timestamp to the cluster node. SetTimestamp(ts time.Time) // Timestamp returns a phisical timestamp of the cluster node. Timestamp() time.Time // SetStatus sets a status to the cluster node. SetStatus(state NodeStatus) // Status returns a status of the cluster node. Status() NodeStatus // Equals returns true if the specified cluster node is same as this node. Equals(node Node) bool // Lock locks the cluster node. Lock() // Unlock unlocks the cluster node. Unlock() }
Node represents a cluster node.
type NodeStatus ¶
type NodeStatus int
NodeStatus represents a cluster node status.
const ( // NodeUnknown represents an unknown node status. NodeUnknown NodeStatus = iota // NodeIdle represents an idle node status. NodeIdle // NodeJoining represents a joining node status. NodeJoining // NodeUp represents a running node status. NodeUp // NodeDown represents a down node status. NodeDown // NodeLeaving represents a leaving node status. NodeLeaving // NodeExiting represents an exiting node status. NodeExiting // NodeRemoved represents a removed node status. NodeRemoved // NodeAborted represents an aborted node status. NodeAborted // NodeUnreachable represents an unreachable node status. NodeUnreachable )
func NewNodeStatusWith ¶
func NewNodeStatusWith(s string) NodeStatus
NewNodeStatusWith returns a new node status with the specified string.
func (NodeStatus) String ¶
func (t NodeStatus) String() string
String represents a string of the node status.
Click to show internal directories.
Click to hide internal directories.