store

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Id        []byte
	Mutex     *sync.RWMutex
	Slots     map[string]Slot
	MustWrite bool
	ReplState map[uint64]*ReplNodeState // replNodeId
}

Second layer of division of the Store

Child of Part

Contains the slots with values and metadata

MustWrite flag is true if changes have been made since last disk-write. MustSync flag is true for each node if changes have been made since last sync

func NewBlock

func NewBlock(id []byte) *Block

func (*Block) ReadFromFile

func (b *Block) ReadFromFile(dir string)

Decodes block file & populates slots

func (*Block) WriteToFile

func (b *Block) WriteToFile(dir string)

Encodes block slots as gob, and writes to file

type BlockManifest

type BlockManifest struct {
	BlockId []byte
}

type Manifest

type Manifest []PartManifest

func (*Manifest) DecodeFrom

func (v *Manifest) DecodeFrom(b []byte) error

func (*Manifest) Encode

func (v *Manifest) Encode() ([]byte, error)

type Part

type Part struct {
	Id     []byte
	Blocks map[uint64]*Block
}

First layer of division of the Store

func NewPart

func NewPart(id []byte) Part

type PartManifest

type PartManifest struct {
	PartId []byte
	Blocks []BlockManifest
}

type ReplNodeState

type ReplNodeState struct {
	MustSync bool
}

type Slot

type Slot struct {
	Value    []byte
	Expires  int64
	Modified int64
}

Contains a value & associated metadata

type Store

type Store struct {
	Parts map[uint64]*Part
	Dir   string
}

func NewStore

func NewStore() *Store

func (*Store) Count

func (s *Store) Count(key string) uint64

func (*Store) Del

func (s *Store) Del(key string)

Remove slot with specified key

TODO: add key to list of deletes to replicate

func (*Store) Get

func (s *Store) Get(key string) (*Slot, bool)

Get slot for specified key from appropriate partition

func (*Store) List

func (s *Store) List(key string, bufferSize int) <-chan string

Returns channel for list of matching keys

If a namespace is given only that namespace will be searched

func (*Store) Persist

func (st *Store) Persist(dir string, period int)

While watch() only takes care of writing to partitions, will only watch if persistence is enabled

func (*Store) ServeConn

func (st *Store) ServeConn(conn net.Conn, authSecret string, bufferSize int)

func (*Store) Set

func (s *Store) Set(key string, slot Slot, repl bool)

Set specified slot in appropriate block

func (*Store) WriteAllBlocks

func (st *Store) WriteAllBlocks(dir string)

type VersionVector

type VersionVector map[string]uint64 // map of nodeId:version

Jump to

Keyboard shortcuts

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