ha

package
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ApplyTTL = time.Second

Variables

This section is empty.

Functions

func NewFSM

func NewFSM(base db.Provider) raft.FSM

func NewProvider

func NewProvider(r *raft.Raft, base db.Provider) db.Provider

NewProvider returns a new db.Provider that uses raft to distribute writes. Reads are always local to the base provider.

Types

type DB

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

func NewDB

func NewDB(db *badger.DB) *DB

func (*DB) DeleteRange

func (db *DB) DeleteRange(min, max uint64) error

func (*DB) FirstIndex

func (db *DB) FirstIndex() (v uint64, err error)

func (*DB) Get

func (db *DB) Get(key []byte) (v []byte, err error)

func (*DB) GetLog

func (db *DB) GetLog(index uint64, log *raft.Log) error

func (*DB) GetUint64

func (db *DB) GetUint64(key []byte) (uint64, error)

func (*DB) LastIndex

func (db *DB) LastIndex() (v uint64, err error)

func (*DB) Set

func (db *DB) Set(key, value []byte) error

func (*DB) SetUint64

func (db *DB) SetUint64(key []byte, value uint64) error

func (*DB) StoreLog

func (db *DB) StoreLog(log *raft.Log) error

func (*DB) StoreLogs

func (db *DB) StoreLogs(logs []*raft.Log) error

type Ha added in v0.0.33

type Ha struct {
	Raft    *raft.Raft
	Transit *Transit
	// contains filtered or unexported fields
}

func Get added in v0.0.33

func Get(ctx context.Context) *Ha

func Open added in v0.0.33

func Open(ctx context.Context) (context.Context, *Ha)

func (*Ha) Close added in v0.0.33

func (h *Ha) Close() error

type ProtoTransit added in v0.0.31

type ProtoTransit struct {
	raftv1.UnsafeTransportServer
	// contains filtered or unexported fields
}

func (*ProtoTransit) AppendEntries added in v0.0.31

func (*ProtoTransit) AppendEntriesPipeline added in v0.0.31

func (t *ProtoTransit) AppendEntriesPipeline(s raftv1.Transport_AppendEntriesPipelineServer) error

func (*ProtoTransit) InstallSnapshot added in v0.0.31

func (*ProtoTransit) RequestVote added in v0.0.31

func (*ProtoTransit) TimeoutNow added in v0.0.31

type Transit

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

func NewTransport

func NewTransport(ctx context.Context, addr raft.ServerAddress, timeout time.Duration) *Transit

func (*Transit) AppendEntries

func (t *Transit) AppendEntries(
	id raft.ServerID,
	target raft.ServerAddress,
	args *raft.AppendEntriesRequest, resp *raft.AppendEntriesResponse) error

func (*Transit) AppendEntriesPipeline

func (t *Transit) AppendEntriesPipeline(id raft.ServerID, target raft.ServerAddress) (raft.AppendPipeline, error)

func (*Transit) Close

func (t *Transit) Close() error

func (*Transit) Consumer

func (t *Transit) Consumer() <-chan raft.RPC

func (*Transit) DecodePeer

func (*Transit) DecodePeer(buf []byte) raft.ServerAddress

func (*Transit) EncodePeer

func (*Transit) EncodePeer(id raft.ServerID, p raft.ServerAddress) []byte

func (*Transit) InstallSnapshot

func (t *Transit) InstallSnapshot(id raft.ServerID, target raft.ServerAddress, args *raft.InstallSnapshotRequest, resp *raft.InstallSnapshotResponse, data io.Reader) error

func (*Transit) LocalAddr

func (t *Transit) LocalAddr() raft.ServerAddress

func (*Transit) Register added in v0.0.31

func (t *Transit) Register(s *grpc.Server)

func (*Transit) RequestVote

func (t *Transit) RequestVote(id raft.ServerID,
	target raft.ServerAddress,
	args *raft.RequestVoteRequest, resp *raft.RequestVoteResponse) error

func (*Transit) SetHeartbeatHandler

func (t *Transit) SetHeartbeatHandler(cb func(rpc raft.RPC))

func (*Transit) TimeoutNow

func (t *Transit) TimeoutNow(id raft.ServerID, target raft.ServerAddress, args *raft.TimeoutNowRequest, resp *raft.TimeoutNowResponse) error

Jump to

Keyboard shortcuts

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