raft

package
v0.0.0-...-4813e5b Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported = errors.ErrUnsupported
	ErrTermZero    = errors.New("Term zero")
)

Functions

This section is empty.

Types

type Application

type Application interface {
	// Init
	Init(ctx context.Context) error

	// PrepareApply is to prepare for update scoped resource
	PrepareUpdate(ctx context.Context) (context.Context, context.CancelFunc, error)

	//make it easier for everyone..
	OnUpdate(ctx context.Context, e Entry) (OnAfterApply, error)

	// Apply to place the code to commit to disk or "Sync"
	Apply(ctx context.Context) error

	// Lookup
	Lookup(ctx context.Context, key interface{}) (interface{}, error)
}

Application represents a dragonboat state machine application

type ApplicationV2

type ApplicationV2 interface {
	// Simpler API for distributed state machine
	// If return error, we will acknowledge it as applied. If you don't want, just crash the state machine.
	OnUpdateV2(ctx context.Context, entry EntryV2) (any, error)
}

exploring etcd raft / make it simpler compared to Application or just EtcdApplication

type ApplicationV2WithSnapshot

type ApplicationV2WithSnapshot interface {
	// write to writer, with the size hint. Size hint must be exact according to deepwiki desc.
	WriteSnapshot(writer io.Writer) (int, error)
}

type Command

type Command string

type Entry

type Entry struct {
	*sm.Entry
	Index   uint64
	Command Command
	Value   []byte

	// Replica that triggered the update
	ReplicaID *uint64
}

type EntryV2

type EntryV2 struct {
	Index          uint64 `json:"index"`
	Term           uint64 `json:"term"`
	SourceNodeID   uint64 `json:"source_node_id"`
	SubscriptionID string `json:"subscription_id"` // or subscription ID

	Data json.RawMessage `json:"data"`
}

type EventLeaderUpdate

type EventLeaderUpdate raftio.LeaderInfo

type LeaderListener

type LeaderListener func(ctx context.Context, term uint64, leaderID uint64) error

type OnAfterApply

type OnAfterApply func() (Result, error)

type Proposer

type Proposer interface {
	Propose(ctx context.Context, value []byte) (any, error)
}

maybe propose async as well

type Result

type Result sm.Result

type ResultV2

type ResultV2 struct {
	// or code
	Value uint64

	SubscriptionID string

	// the payload
	Data  any
	Error error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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