lib

package
v0.0.0-...-2cfabc9 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package lib provides a collection of types and methods to run a key-value storage compatible to the dkvs specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Master

type Master interface {
	Node
	// Cluster collects all to this master connected nodes.
	Cluster() ([]Node, error)
	// Replicas collects all master replicas in this cluster.
	Replicas() ([]Master, error)
	// Join tells this master than the node wants to join its cluster.
	Join(n Node) error
	// Assist tells this master that another secondary master wants to join its cluster.
	Assist(m Master) error
}

Master is a superset of a cluster node with administrative abilities.

type Node

type Node interface {
	// Read searches the value and revision mapped to the key.
	Read(key string) (string, Revision, error)
	// Store puts the key-value pair in the data store.
	Store(key, value string, rev Revision) error
	// Keys collects all keys mapped to values.
	Keys() ([]string, error)
	// Mirror collects all key-value pairs from the peers and stores them locally.
	Mirror([]Node) error
	// Revision updates the internal revision and always returns the latest revision.
	Revision(rev Revision) (Revision, error)

	// Address returns this node's address.
	Address() string
	// Role returns the node's role.
	Role() (Role, error)

	// Rebuild forces the node to refetch master replicas and cluster nodes.
	Rebuild() error
	// Status returns the current actor state of the node.
	Status() Status
	// Shutdown stops the node.
	Shutdown() error

	// LocalKeys collects all local keys that are mapped to values.
	LocalKeys() ([]string, error)
	// LocalRead searches locally for the value-revision pair mapped to the key.
	LocalRead(key string) (string, Revision, error)
	// LocalStore puts the key-value pair in the local key store.
	LocalStore(key, value string, rev Revision) error
}

Node is a part of a DKVS cluster.

type Revision

type Revision []byte

Revision stores a byte-encoded versioning ID.

func ToRevision

func ToRevision(s string) (Revision, error)

ToRevision converts the string into a revision ID.

func (Revision) Increase

func (rev Revision) Increase() Revision

Increase pushes the revision ID one up.

func (Revision) IsNewer

func (rev Revision) IsNewer(than Revision) bool

IsNewer checks if this revision is newer than the given one.

func (Revision) String

func (rev Revision) String() string

String converts the revision into a string representation.

type Role

type Role int

Role is a node's role within the cluster.

const (
	// RoleMasterPrimary is the primary cluster master role.
	RoleMasterPrimary Role = iota
	// RoleMaster is the secondary cluster master role.
	RoleMaster
	// RoleSlave is the passive cluster role.
	RoleSlave
)

type Status

type Status int

Status is a node's internal status.

const (
	// StatusDown is the offline state of a node.
	StatusDown Status = iota
	// StatusReady is the online state of a node.
	StatusReady
	// StatusShutdown is the soon-down state of a node.
	StatusShutdown
	// StatusStartup is the soon-ready state of a node.
	StatusStartup
)

Directories

Path Synopsis
Package local provides a master-slave implementation to run on a local machine.
Package local provides a master-slave implementation to run on a local machine.
cluster
Package cluster provides functionality for managing node cluster sets.
Package cluster provides functionality for managing node cluster sets.
hashtable
Package hashtable provides functionality for storing and retrieving key-value pairs associated with a specific revision.
Package hashtable provides functionality for storing and retrieving key-value pairs associated with a specific revision.
replicas
Package replicas provides functionality to manage master node sets.
Package replicas provides functionality to manage master node sets.
Package remote provides a remote interface for network nodes.
Package remote provides a remote interface for network nodes.

Jump to

Keyboard shortcuts

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