core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyKey                   = fmt.Errorf("empty key")
	ErrNotFound                   = fmt.Errorf("not found")
	ErrNotLeader                  = fmt.Errorf("not leader")
	ErrUnknownEntryType           = fmt.Errorf("unknown entry type")
	ErrReplicateQuorumUnreachable = fmt.Errorf("replicate quorum unreachable")
)

Functions

func KeyToUint

func KeyToUint(b []byte) uint64

func ToGrpcError

func ToGrpcError(err error) error

func UintToKey

func UintToKey(index uint64) []byte

Types

type Command

type Command string
const (
	Set Command = "SET"
	Del Command = "DEL"
)

func (Command) String

func (c Command) String() string

type Entry

type Entry struct {
	// Term is the term of the log entry
	Term uint64 `json:"term"`

	// Index is the index of the log entry
	Index uint64 `json:"index"`

	// Data is the command of the log entry as an array of strings
	// Example: ["SET", "key", "value"], ["DEL", "key"]
	Data []string `json:"data"`
}

func EntryFromBytes

func EntryFromBytes(bytes []byte) (*Entry, error)

func (*Entry) ToBytes

func (e *Entry) ToBytes() ([]byte, error)

type Node

type Node struct {
	ID      ServerID
	Address string
}

type ServerID

type ServerID uint64

Jump to

Keyboard shortcuts

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