Documentation ¶
Overview ¶
Package extension contains helper types, beyond the core CASPaxos protocol. It's meant to be a bridge or adapter, towards a usable data system.
Index ¶
- type Acceptor
- type CASError
- type Cluster
- type ClusterOperator
- func (op ClusterOperator) Address() string
- func (op ClusterOperator) ClusterState(ctx context.Context) (s ClusterState, err error)
- func (op ClusterOperator) GarbageCollect(ctx context.Context, key string) error
- func (op ClusterOperator) GrowCluster(ctx context.Context, target protocol.Acceptor) error
- func (op ClusterOperator) ShrinkCluster(ctx context.Context, target protocol.Acceptor) error
- type ClusterState
- type ClusterUser
- func (u ClusterUser) Address() string
- func (u ClusterUser) CAS(ctx context.Context, key string, currentVersion uint64, nextValue []byte) (version uint64, value []byte, err error)
- func (u ClusterUser) Read(ctx context.Context, key string) (version uint64, value []byte, err error)
- func (u ClusterUser) Watch(ctx context.Context, key string, values chan<- []byte) error
- type OperatorNode
- type Proposer
- type ProposerState
- type UserNode
- type ValueWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Acceptor ¶
type Acceptor interface { protocol.Addresser protocol.Preparer protocol.Accepter protocol.RejectRemover ValueWatcher }
Acceptor extends the core protocol acceptor.
type CASError ¶
type CASError struct{ Err error }
CASError indicates a conflict during CAS, likely a version conflict.
type Cluster ¶
type Cluster interface { Acceptors(context.Context) ([]Acceptor, error) Proposers(context.Context) ([]Proposer, error) OperatorNodes(context.Context) ([]OperatorNode, error) UserNodes(context.Context) ([]UserNode, error) }
Cluster models the methods that operator and user nodes need from a cluster.
type ClusterOperator ¶
type ClusterOperator struct {
// contains filtered or unexported fields
}
ClusterOperator provides OperatorNode methods over a cluster.
func NewClusterOperator ¶
func NewClusterOperator(address string, c Cluster, logger log.Logger) *ClusterOperator
NewClusterOperator returns a usable ClusterOperator, which is an implementation of the operator node interface that wraps the passed cluster. It should be uniquely identified by address.
func (ClusterOperator) Address ¶
func (op ClusterOperator) Address() string
Address implements OperatorNode.
func (ClusterOperator) ClusterState ¶
func (op ClusterOperator) ClusterState(ctx context.Context) (s ClusterState, err error)
ClusterState implements OperatorNode.
func (ClusterOperator) GarbageCollect ¶
func (op ClusterOperator) GarbageCollect(ctx context.Context, key string) error
GarbageCollect implements OperatorNode.
func (ClusterOperator) GrowCluster ¶
GrowCluster implements OperatorNode.
func (ClusterOperator) ShrinkCluster ¶
ShrinkCluster implements OperatorNode.
type ClusterState ¶
type ClusterState struct { Acceptors []string `json:"acceptors"` Proposers []ProposerState `json:"proposers"` OperatorNodes []string `json:"operator_nodes"` UserNodes []string `json:"user_nodes"` }
ClusterState captures the current state of the cluster.
type ClusterUser ¶
type ClusterUser struct {
// contains filtered or unexported fields
}
ClusterUser provides UserNode methods over a cluster.
func NewClusterUser ¶
func NewClusterUser(address string, c Cluster, logger log.Logger) *ClusterUser
NewClusterUser returns a usable ClusterUser, which is an implementation of the user node interface that wraps the passed cluster. It should be uniquely identified by address.
func (ClusterUser) CAS ¶
func (u ClusterUser) CAS(ctx context.Context, key string, currentVersion uint64, nextValue []byte) (version uint64, value []byte, err error)
CAS implements UserNode.
type OperatorNode ¶
type OperatorNode interface { protocol.Addresser ClusterState(ctx context.Context) (ClusterState, error) GrowCluster(ctx context.Context, target protocol.Acceptor) error ShrinkCluster(ctx context.Context, target protocol.Acceptor) error GarbageCollect(ctx context.Context, key string) error }
OperatorNode models the functionality that a cluster admin needs.
type Proposer ¶
type Proposer interface { protocol.Addresser Read(ctx context.Context, key string) (version uint64, value []byte, err error) CAS(ctx context.Context, key string, currentVersion uint64, nextValue []byte) (version uint64, value []byte, err error) protocol.ConfigurationChanger protocol.FastForwarder protocol.AcceptorLister }
Proposer models serializable methods of a proposer. Notably, the Watch method has the same signature but returns values instead of states; and the Propose method is dropped in favor of Read and CAS. The CAS protocol is taken from the paper, with a (Version, Value) tuple.
type ProposerState ¶
type ProposerState struct { Address string `json:"address"` Preparers []string `json:"preparers"` Accepters []string `json:"accepters"` }
ProposerState captures the current state of a proposer in the cluster.
type UserNode ¶
type UserNode interface { protocol.Addresser Read(ctx context.Context, key string) (version uint64, value []byte, err error) CAS(ctx context.Context, key string, currentVersion uint64, nextValue []byte) (version uint64, value []byte, err error) Watch(ctx context.Context, key string, values chan<- []byte) error // TODO(pb): correct API? }
UserNode models the user API supported by the cluster.
type ValueWatcher ¶
ValueWatcher wraps protocol.StateWatcher. Implementations must perform (Version, Value) tuple deserialization of the received states to convert them to values before sending them on.