raft

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFSM

func NewFSM(opts FSMOpts) raft.FSM

Types

type FSM

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

func (*FSM) Apply

func (fsm *FSM) Apply(log *raft.Log) interface{}

Apply Implements raft.FSM interface

func (*FSM) Restore

func (fsm *FSM) Restore(snapshot io.ReadCloser) error

Restore implements raft.FSM interface

func (*FSM) Snapshot

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

Snapshot implements raft.FSM interface

type FSMOpts

type FSMOpts struct {
	Config                config.Config
	EchoVault             types.EchoVault
	GetState              func() map[string]internal.KeyData
	GetCommand            func(command string) (types.Command, error)
	DeleteKey             func(ctx context.Context, key string) error
	StartSnapshot         func()
	FinishSnapshot        func()
	SetLatestSnapshotTime func(msec int64)
}

type Opts

type Opts struct {
	Config                config.Config
	EchoVault             types.EchoVault
	GetState              func() map[string]internal.KeyData
	GetCommand            func(command string) (types.Command, error)
	DeleteKey             func(ctx context.Context, key string) error
	StartSnapshot         func()
	FinishSnapshot        func()
	SetLatestSnapshotTime func(msec int64)
}

type Raft

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

func NewRaft

func NewRaft(opts Opts) *Raft

func (*Raft) AddVoter

func (r *Raft) AddVoter(
	id raft.ServerID,
	address raft.ServerAddress,
	prevIndex uint64,
	timeout time.Duration,
) error

func (*Raft) Apply

func (r *Raft) Apply(cmd []byte, timeout time.Duration) raft.ApplyFuture

func (*Raft) HasJoinedCluster

func (r *Raft) HasJoinedCluster() bool

func (*Raft) IsRaftLeader

func (r *Raft) IsRaftLeader() bool

func (*Raft) RaftInit

func (r *Raft) RaftInit(ctx context.Context)

func (*Raft) RaftShutdown

func (r *Raft) RaftShutdown()

func (*Raft) RemoveServer

func (r *Raft) RemoveServer(meta memberlist.NodeMeta) error

func (*Raft) TakeSnapshot

func (r *Raft) TakeSnapshot() error

type Snapshot

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

func NewFSMSnapshot

func NewFSMSnapshot(opts SnapshotOpts) *Snapshot

func (*Snapshot) Persist

func (s *Snapshot) Persist(sink raft.SnapshotSink) error

Persist implements FSMSnapshot interface

func (*Snapshot) Release

func (s *Snapshot) Release()

Release implements FSMSnapshot interface

type SnapshotOpts

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

Jump to

Keyboard shortcuts

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