extension

package
v0.0.0-...-6e7a5f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2018 License: Apache-2.0 Imports: 7 Imported by: 2

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acceptor

Acceptor extends the core protocol acceptor.

type CASError

type CASError struct{ Err error }

CASError indicates a conflict during CAS, likely a version conflict.

func (CASError) Error

func (e CASError) Error() string

Error implements the error interface.

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

func (op ClusterOperator) GrowCluster(ctx context.Context, target protocol.Acceptor) error

GrowCluster implements OperatorNode.

func (ClusterOperator) ShrinkCluster

func (op ClusterOperator) ShrinkCluster(ctx context.Context, target protocol.Acceptor) error

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) Address

func (u ClusterUser) Address() string

Address implements UserNode.

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.

func (ClusterUser) Read

func (u ClusterUser) Read(ctx context.Context, key string) (version uint64, value []byte, err error)

Read implements UserNode.

func (ClusterUser) Watch

func (u ClusterUser) Watch(ctx context.Context, key string, values chan<- []byte) error

Watch 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

type ValueWatcher interface {
	Watch(ctx context.Context, key string, values chan<- []byte) error
}

ValueWatcher wraps protocol.StateWatcher. Implementations must perform (Version, Value) tuple deserialization of the received states to convert them to values before sending them on.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL