db

package
v0.0.0-...-6206b6d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conflict

func Conflict(gamma *Command, delta *Command) bool

Conflict checks if two commands are conflicting as reorder them will end in different states

func ConflictBatch

func ConflictBatch(batch1 []Command, batch2 []Command) bool

ConflictBatch checks if two batchs of commands are conflict

Types

type Command

type Command struct {
	Key       Key
	Value     Value
	Type      CommandType
	ClientID  idservice.ID
	CommandID int
}

Commands of key-value database

func (Command) Empty

func (c Command) Empty() bool

func (Command) Equal

func (c Command) Equal(a Command) bool

func (Command) Hash

func (c Command) Hash() string

func (Command) String

func (c Command) String() string

type CommandType

type CommandType int
const (
	CmdRead CommandType = iota
	CmdWrite
	CmdDelete
	CmdImmediateRead
	CmdOneNodeRead
	CmdConfig
)

type Database

type Database interface {
	Execute(Command) Value
	History(Key) []Value
	Get(Key) Value
	Put(Key, Value)
}

Database defines a database interface TODO replace with more general StateMachine interface

func NewDatabase

func NewDatabase() Database

NewDatabase returns database that impelements Database interface

type Key

type Key int

Key type of the key-value database TODO key should be general too

type Value

type Value []byte

Value type of key-value database

func (Value) Equals

func (v Value) Equals(v2 Value) bool

Jump to

Keyboard shortcuts

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