server

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

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

Go to latest
Published: Nov 7, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(s string) uint32

Hash returns the 32bit hash for a given key

Types

type Chunk

type Chunk struct {
}

Chunk represents a single chunk in the system

type ClusterConfig

type ClusterConfig struct {
	Size ClusterSize
	// Chunks is the list of all chunks in the system
	Chunks []Chunk
	// Shards is the list of shards in the system
	Shards []Shard
}

ClusterConfig holds the current cluster configuration

func (*ClusterConfig) Chunk

func (config *ClusterConfig) Chunk(s string) uint32

Chunk returns the 16bit chunk number for the given key.

type ClusterSize

type ClusterSize uint8

ClusterSize is an enumeration for keeping track of how large a cluster is

var (
	// SmallCluster is for a cluster of up to 256 shards
	SmallCluster ClusterSize = 1
	// MediumCluster is for a cluster of up to 65,536 shards
	MediumCluster ClusterSize = 2
	// LargeCluster is for a cluster of up to 1,6777,216 shards
	LargeCluster ClusterSize = 3
	// HugeCluster is for a cluster of up to 4,294,967,296 shards
	HugeCluster ClusterSize = 4
)

noinspection GoUnusedGlobalVariable

type DBServer

type DBServer struct {
	Logger  *log.Logger
	Storage *storage.Instance
	// contains filtered or unexported fields
}

DBServer is an instance of the database server

func New

func New(logWriter io.Writer, dbPath string) *DBServer

New creates a new instance of the database server

func (*DBServer) Get

func (s *DBServer) Get(ctx context.Context, request *api.IDRequest) (*api.Response, error)

Get returns a value for a given key

func (*DBServer) Remove

func (s *DBServer) Remove(ctx context.Context, request *api.IDRequest) (*api.Response, error)

Remove removes a given key

func (*DBServer) Set

func (s *DBServer) Set(ctx context.Context, request *api.IDValueRequest) (*api.Response, error)

Set sets a value for a given key

func (*DBServer) Stop

func (s *DBServer) Stop()

Stop shuts down the database server

func (*DBServer) Time

func (s *DBServer) Time(ctx context.Context, request *api.EmptyRequest) (*api.Response, error)

Time returns the current time

type Shard

type Shard struct {
	ID      uuid.UUID
	Address string
}

Shard represents a single shard in the system that can contain some set of chunks

Jump to

Keyboard shortcuts

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