core

package
v0.0.0-...-4406380 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chooser

type Chooser interface {
	// SetBuckets sets the list of known buckets from which the chooser should select
	SetBuckets([]string) error
	// Choose returns a bucket for a given key
	Choose(key string) string
	// Buckets returns the list of known buckets
	Buckets() []string
}

Chooser maps keys to shards

type KVStore

type KVStore struct {
	// contains filtered or unexported fields
}

KVStore is a sharded key-value store

func New

func New(chooser Chooser, shards []Shard) *KVStore

New returns a KVStore that uses chooser to shard the keys across the provided shards

func (*KVStore) AddShard

func (kv *KVStore) AddShard(shard string, storage Storage)

AddShard adds a shard from the list of known shards

func (*KVStore) BeginMigration

func (kv *KVStore) BeginMigration(continuum Chooser)

BeginMigration begins a continuum migration. All the shards in the new continuum must already be known to the KVStore via AddShard().

func (*KVStore) BeginMigrationWithShards

func (kv *KVStore) BeginMigrationWithShards(continuum Chooser, shards []Shard)

BeginMigrationWithShards begins a continuum migration using the new set of shards.

func (*KVStore) DeleteShard

func (kv *KVStore) DeleteShard(shard string)

DeleteShard removes a shard from the list of known shards

func (*KVStore) Destroy

func (kv *KVStore) Destroy(ctx context.Context) error

func (*KVStore) EndMigration

func (kv *KVStore) EndMigration()

EndMigration ends a continuum migration and marks the migration continuum as the new primary

func (*KVStore) FindPartition

func (kv *KVStore) FindPartition(tblName, rowKey string) (int, error)

func (*KVStore) Get

func (kv *KVStore) Get(ctx context.Context, tblName, rowKey, columnKey string, refKey int64) (cell models.Cell, found bool, err error)

func (*KVStore) GetLatest

func (kv *KVStore) GetLatest(ctx context.Context, tblName, rowKey, columnKey string) (cell models.Cell, found bool, err error)

func (*KVStore) PartitionRead

func (kv *KVStore) PartitionRead(ctx context.Context, tblName string, partitionNumber int, location string, value int64, limit int) (cells []models.Cell, found bool, err error)

func (*KVStore) Put

func (kv *KVStore) Put(ctx context.Context, tblName, rowKey, columnKey string, refKey int64, body string) error

func (*KVStore) ResetConnection

func (kv *KVStore) ResetConnection(ctx context.Context, key string) error

func (*KVStore) WithName

func (kv *KVStore) WithName(name string) *KVStore

type Shard

type Shard struct {
	Name    string
	Backend Storage
}

Shard is a named storage backend

type Storage

type Storage interface {
	// Get the cell designated (row key, column key, ref key)
	Get(ctx context.Context, tblName string, rowKey string, columnKey string, refKey int64) (cell models.Cell, found bool, err error)

	// GetLatest returns the latest value for a given rowKey and columnKey, and a bool indicating if the key was present
	GetLatest(ctx context.Context, tblName string, rowKey string, columnKey string) (cell models.Cell, found bool, err error)

	// PartitionRead returns 'limit' cells after 'location' from shard 'shard_no'
	PartitionRead(ctx context.Context, tblName string, partitionNumber int, location string, value int64, limit int) (cells []models.Cell, found bool, err error)

	// Put inits a cell with given row key, column key, and ref key
	Put(ctx context.Context, tblName string, rowKey string, columnKey string, refKey int64, body string) (err error)

	// FindPartition returns the partition number for a specific rowKey
	FindPartition(tblName, rowKey string) int

	// ResetConnection reinitializes the connection for the shard responsible for a key
	ResetConnection(ctx context.Context, key string) error

	// Destroy cleans up any resources, etc.
	Destroy(ctx context.Context) error
}

Storage is a key-value storage backend

Jump to

Keyboard shortcuts

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