badgerRaft

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const C_CommitTxn int64 = 15774688
View Source
const C_Delete int64 = 1035893169
View Source
const C_Get int64 = 3312871568
View Source
const C_Set int64 = 3730400060
View Source
const C_StartTxn int64 = 605208098
View Source
const C_StopTxn int64 = 1239816782
View Source
const C_StoreCommand int64 = 3294788005

Variables

View Source
var (
	ErrKeyNotFound         = badger.ErrKeyNotFound
	DefaultIteratorOptions = badger.DefaultIteratorOptions
)
View Source
var (
	CommandType_name = map[int32]string{
		0: "CTStartTxn",
		1: "CTStopTxn",
		2: "CTCommitTxn",
		3: "CTSet",
		4: "CTDelete",
		5: "CTGet",
	}
	CommandType_value = map[string]int32{
		"CTStartTxn":  0,
		"CTStopTxn":   1,
		"CTCommitTxn": 2,
		"CTSet":       3,
		"CTDelete":    4,
		"CTGet":       5,
	}
)

Enum value maps for CommandType.

View Source
var (
	ErrDuplicateID = fmt.Errorf("duplicate id")
	ErrTxnNotFound = fmt.Errorf("txn not found")
	ErrUnknown     = fmt.Errorf("unknown")
)
View Source
var File_commands_proto protoreflect.FileDescriptor
View Source
var PoolCommitTxn = poolCommitTxn{}
View Source
var PoolDelete = poolDelete{}
View Source
var PoolGet = poolGet{}
View Source
var PoolSet = poolSet{}
View Source
var PoolStartTxn = poolStartTxn{}
View Source
var PoolStopTxn = poolStopTxn{}
View Source
var PoolStoreCommand = poolStoreCommand{}

Functions

This section is empty.

Types

type CommandType

type CommandType int32

StoreCommandType

const (
	CommandType_CTStartTxn  CommandType = 0
	CommandType_CTStopTxn   CommandType = 1
	CommandType_CTCommitTxn CommandType = 2
	CommandType_CTSet       CommandType = 3
	CommandType_CTDelete    CommandType = 4
	CommandType_CTGet       CommandType = 5
)

func (CommandType) Descriptor

func (CommandType) Enum

func (x CommandType) Enum() *CommandType

func (CommandType) EnumDescriptor deprecated

func (CommandType) EnumDescriptor() ([]byte, []int)

Deprecated: Use CommandType.Descriptor instead.

func (CommandType) Number

func (x CommandType) Number() protoreflect.EnumNumber

func (CommandType) String

func (x CommandType) String() string

func (CommandType) Type

type CommitTxn

type CommitTxn struct {
	ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	// contains filtered or unexported fields
}

func (*CommitTxn) DeepCopy

func (x *CommitTxn) DeepCopy(z *CommitTxn)

func (*CommitTxn) Descriptor deprecated

func (*CommitTxn) Descriptor() ([]byte, []int)

Deprecated: Use CommitTxn.ProtoReflect.Descriptor instead.

func (*CommitTxn) GetID

func (x *CommitTxn) GetID() int64

func (*CommitTxn) Marshal

func (x *CommitTxn) Marshal() ([]byte, error)

func (*CommitTxn) ProtoMessage

func (*CommitTxn) ProtoMessage()

func (*CommitTxn) ProtoReflect

func (x *CommitTxn) ProtoReflect() protoreflect.Message

func (*CommitTxn) Reset

func (x *CommitTxn) Reset()

func (*CommitTxn) String

func (x *CommitTxn) String() string

func (*CommitTxn) Unmarshal

func (x *CommitTxn) Unmarshal(b []byte) error

type Config

type Config struct {
	DirPath             string
	ConflictRetries     int
	ConflictMaxInterval time.Duration
	BatchWorkers        int
	BatchSize           int
}

func DefaultConfig

func DefaultConfig(dataPath string) Config

type Delete

type Delete struct {
	TxnID int64  `protobuf:"varint,1,opt,name=TxnID,proto3" json:"TxnID,omitempty"`
	Key   []byte `protobuf:"bytes,2,opt,name=Key,proto3" json:"Key,omitempty"`
	// contains filtered or unexported fields
}

func (*Delete) DeepCopy

func (x *Delete) DeepCopy(z *Delete)

func (*Delete) Descriptor deprecated

func (*Delete) Descriptor() ([]byte, []int)

Deprecated: Use Delete.ProtoReflect.Descriptor instead.

func (*Delete) GetKey

func (x *Delete) GetKey() []byte

func (*Delete) GetTxnID

func (x *Delete) GetTxnID() int64

func (*Delete) Marshal

func (x *Delete) Marshal() ([]byte, error)

func (*Delete) ProtoMessage

func (*Delete) ProtoMessage()

func (*Delete) ProtoReflect

func (x *Delete) ProtoReflect() protoreflect.Message

func (*Delete) Reset

func (x *Delete) Reset()

func (*Delete) String

func (x *Delete) String() string

func (*Delete) Unmarshal

func (x *Delete) Unmarshal(b []byte) error

type Entry

type Entry = badger.Entry

func NewEntry

func NewEntry(key, value []byte) *Entry

type Get

type Get struct {
	TxnID int64  `protobuf:"varint,1,opt,name=TxnID,proto3" json:"TxnID,omitempty"`
	Key   []byte `protobuf:"bytes,2,opt,name=Key,proto3" json:"Key,omitempty"`
	// contains filtered or unexported fields
}

func (*Get) DeepCopy

func (x *Get) DeepCopy(z *Get)

func (*Get) Descriptor deprecated

func (*Get) Descriptor() ([]byte, []int)

Deprecated: Use Get.ProtoReflect.Descriptor instead.

func (*Get) GetKey

func (x *Get) GetKey() []byte

func (*Get) GetTxnID

func (x *Get) GetTxnID() int64

func (*Get) Marshal

func (x *Get) Marshal() ([]byte, error)

func (*Get) ProtoMessage

func (*Get) ProtoMessage()

func (*Get) ProtoReflect

func (x *Get) ProtoReflect() protoreflect.Message

func (*Get) Reset

func (x *Get) Reset()

func (*Get) String

func (x *Get) String() string

func (*Get) Unmarshal

func (x *Get) Unmarshal(b []byte) error

type Set

type Set struct {
	TxnID int64  `protobuf:"varint,1,opt,name=TxnID,proto3" json:"TxnID,omitempty"`
	Key   []byte `protobuf:"bytes,2,opt,name=Key,proto3" json:"Key,omitempty"`
	Value []byte `protobuf:"bytes,3,opt,name=Value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

func (*Set) DeepCopy

func (x *Set) DeepCopy(z *Set)

func (*Set) Descriptor deprecated

func (*Set) Descriptor() ([]byte, []int)

Deprecated: Use Set.ProtoReflect.Descriptor instead.

func (*Set) GetKey

func (x *Set) GetKey() []byte

func (*Set) GetTxnID

func (x *Set) GetTxnID() int64

func (*Set) GetValue

func (x *Set) GetValue() []byte

func (*Set) Marshal

func (x *Set) Marshal() ([]byte, error)

func (*Set) ProtoMessage

func (*Set) ProtoMessage()

func (*Set) ProtoReflect

func (x *Set) ProtoReflect() protoreflect.Message

func (*Set) Reset

func (x *Set) Reset()

func (*Set) String

func (x *Set) String() string

func (*Set) Unmarshal

func (x *Set) Unmarshal(b []byte) error

type SnapshotBuilder

type SnapshotBuilder struct{}

SnapshotBuilder is used for snapshot of Raft logs

func (SnapshotBuilder) Persist

func (s SnapshotBuilder) Persist(sink raft.SnapshotSink) error

func (SnapshotBuilder) Release

func (s SnapshotBuilder) Release()

type StartTxn

type StartTxn struct {
	ID     int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	Update bool  `protobuf:"varint,2,opt,name=Update,proto3" json:"Update,omitempty"`
	// contains filtered or unexported fields
}

func (*StartTxn) DeepCopy

func (x *StartTxn) DeepCopy(z *StartTxn)

func (*StartTxn) Descriptor deprecated

func (*StartTxn) Descriptor() ([]byte, []int)

Deprecated: Use StartTxn.ProtoReflect.Descriptor instead.

func (*StartTxn) GetID

func (x *StartTxn) GetID() int64

func (*StartTxn) GetUpdate

func (x *StartTxn) GetUpdate() bool

func (*StartTxn) Marshal

func (x *StartTxn) Marshal() ([]byte, error)

func (*StartTxn) ProtoMessage

func (*StartTxn) ProtoMessage()

func (*StartTxn) ProtoReflect

func (x *StartTxn) ProtoReflect() protoreflect.Message

func (*StartTxn) Reset

func (x *StartTxn) Reset()

func (*StartTxn) String

func (x *StartTxn) String() string

func (*StartTxn) Unmarshal

func (x *StartTxn) Unmarshal(b []byte) error

type StopTxn

type StopTxn struct {
	ID     int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	Commit bool  `protobuf:"varint,2,opt,name=Commit,proto3" json:"Commit,omitempty"`
	// contains filtered or unexported fields
}

func (*StopTxn) DeepCopy

func (x *StopTxn) DeepCopy(z *StopTxn)

func (*StopTxn) Descriptor deprecated

func (*StopTxn) Descriptor() ([]byte, []int)

Deprecated: Use StopTxn.ProtoReflect.Descriptor instead.

func (*StopTxn) GetCommit

func (x *StopTxn) GetCommit() bool

func (*StopTxn) GetID

func (x *StopTxn) GetID() int64

func (*StopTxn) Marshal

func (x *StopTxn) Marshal() ([]byte, error)

func (*StopTxn) ProtoMessage

func (*StopTxn) ProtoMessage()

func (*StopTxn) ProtoReflect

func (x *StopTxn) ProtoReflect() protoreflect.Message

func (*StopTxn) Reset

func (x *StopTxn) Reset()

func (*StopTxn) String

func (x *StopTxn) String() string

func (*StopTxn) Unmarshal

func (x *StopTxn) Unmarshal(b []byte) error

type Store

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

Store is the finite state machine which will be used when Raft is enabled.

func New

func New(cfg Config) (*Store, error)

func (*Store) Apply

func (fsm *Store) Apply(raftLog *raft.Log) interface{}

func (*Store) DB

func (fsm *Store) DB() *store.DB

func (*Store) Restore

func (fsm *Store) Restore(rd io.ReadCloser) error

func (*Store) Shutdown

func (fsm *Store) Shutdown()

func (*Store) Snapshot

func (fsm *Store) Snapshot() (raft.FSMSnapshot, error)

func (*Store) Update

func (fsm *Store) Update(fn func(store.Txn) error) error

func (*Store) UpdateLocal

func (fsm *Store) UpdateLocal(fn func(txn *store.LTxn) error) error

func (*Store) View

func (fsm *Store) View(fn func(store.Txn) error) error

func (*Store) ViewLocal

func (fsm *Store) ViewLocal(fn func(txn *store.LTxn) error) error

type StoreCommand

type StoreCommand struct {
	Type    CommandType `protobuf:"varint,1,opt,name=Type,proto3,enum=badgerRaft.CommandType" json:"Type,omitempty"`
	Payload []byte      `protobuf:"bytes,2,opt,name=Payload,proto3" json:"Payload,omitempty"`
	// contains filtered or unexported fields
}

RaftCommand

func (*StoreCommand) DeepCopy

func (x *StoreCommand) DeepCopy(z *StoreCommand)

func (*StoreCommand) Descriptor deprecated

func (*StoreCommand) Descriptor() ([]byte, []int)

Deprecated: Use StoreCommand.ProtoReflect.Descriptor instead.

func (*StoreCommand) GetPayload

func (x *StoreCommand) GetPayload() []byte

func (*StoreCommand) GetType

func (x *StoreCommand) GetType() CommandType

func (*StoreCommand) Marshal

func (x *StoreCommand) Marshal() ([]byte, error)

func (*StoreCommand) ProtoMessage

func (*StoreCommand) ProtoMessage()

func (*StoreCommand) ProtoReflect

func (x *StoreCommand) ProtoReflect() protoreflect.Message

func (*StoreCommand) Reset

func (x *StoreCommand) Reset()

func (*StoreCommand) String

func (x *StoreCommand) String() string

func (*StoreCommand) Unmarshal

func (x *StoreCommand) Unmarshal(b []byte) error

type Txn

type Txn struct {
	ID int64
	// contains filtered or unexported fields
}

func (*Txn) Delete

func (txn *Txn) Delete(alloc *tools.Allocator, keyParts ...interface{}) error

func (*Txn) Exists

func (txn *Txn) Exists(alloc *tools.Allocator, keyParts ...interface{}) bool

func (*Txn) Get

func (txn *Txn) Get(alloc *tools.Allocator, keyParts ...interface{}) ([]byte, error)

func (*Txn) Set

func (txn *Txn) Set(alloc *tools.Allocator, val []byte, keyParts ...interface{}) error

Jump to

Keyboard shortcuts

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