kv

package
v0.0.0-...-ff31c07 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRequest = errors.New("invalid request")
View Source
var ErrKeyAlreadyLocked = errors.New("key already locked")
View Source
var ErrKeyNotLocked = errors.New("key not locked")
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var ErrUnknownRequestType = errors.New("unknown request type")

Functions

This section is empty.

Types

type Coordinate

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

func NewCoordinator

func NewCoordinator(txm Transactional, r *raft.Raft) *Coordinate

func (*Coordinate) Dispatch

func (c *Coordinate) Dispatch(reqs *OperationGroup[OP]) (*CoordinateResponse, error)

func (*Coordinate) IsLeader

func (c *Coordinate) IsLeader() bool

type CoordinateResponse

type CoordinateResponse struct {
	CommitIndex uint64
}

type Coordinator

type Coordinator interface {
	Dispatch(reqs *OperationGroup[OP]) (*CoordinateResponse, error)
	IsLeader() bool
}

type Elem

type Elem[T OP] struct {
	Op    T
	Key   []byte
	Value []byte
}

Elem is an element of a transaction.

type FSM

type FSM interface {
	raft.FSM
}

func NewKvFSM

func NewKvFSM(store store.Store, lockStore store.TTLStore) FSM

type OP

type OP int

OP is an operation type.

const (
	Put OP = iota
	Del
)

Operation types.

type OperationGroup

type OperationGroup[T OP] struct {
	Elems []*Elem[T]
	IsTxn bool
}

OperationGroup is a group of operations that should be executed atomically.

type TransactionManager

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

func NewTransaction

func NewTransaction(raft *raft.Raft) *TransactionManager

func (*TransactionManager) Abort

func (t *TransactionManager) Abort(reqs []*pb.Request) (*TransactionResponse, error)

func (*TransactionManager) Commit

func (t *TransactionManager) Commit(reqs []*pb.Request) (*TransactionResponse, error)

type TransactionResponse

type TransactionResponse struct {
	CommitIndex uint64
}

type Transactional

type Transactional interface {
	Commit(reqs []*pb.Request) (*TransactionResponse, error)
	Abort(reqs []*pb.Request) (*TransactionResponse, error)
}

Jump to

Keyboard shortcuts

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