Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin interface {
LeaderView
StatusReader
ConfigReader
AddVoter(ctx context.Context, id string, address string, prevIndex uint64) (uint64, error)
RemoveServer(ctx context.Context, id string, prevIndex uint64) (uint64, error)
TransferLeadership(ctx context.Context) error
TransferLeadershipToServer(ctx context.Context, id string, address string) error
}
type ConfigReader ¶
type ConfigReader interface {
Configuration(ctx context.Context) (Configuration, error)
}
type Configuration ¶
type Configuration struct {
Servers []Server
}
type Engine ¶
type Engine interface {
Proposer
LeaderView
StatusReader
ConfigReader
io.Closer
}
type Factory ¶
type Factory interface {
EngineType() string
Create(cfg FactoryConfig) (*FactoryResult, error)
}
Factory creates raft engine instances. Engine-specific configuration (timeouts, tick intervals, etc.) is provided at factory construction time; the Create method receives only engine-agnostic parameters.
type FactoryConfig ¶
type FactoryConfig struct {
LocalID string
LocalAddress string
DataDir string
Peers []Server
Bootstrap bool
StateMachine StateMachine
}
FactoryConfig holds engine-agnostic parameters for creating a raft engine.
type FactoryResult ¶
type FactoryResult struct {
Engine Engine
RegisterTransport func(grpc.ServiceRegistrar)
// Close releases engine-specific resources that are not owned by
// Engine.Close (e.g. raft log stores, transport managers). Callers
// must call Engine.Close first to ensure the raft instance is fully
// shut down before the underlying stores and transports are released.
Close func() error
}
FactoryResult holds the output of Factory.Create.
type HealthReader ¶
type LeaderInfo ¶
type LeaderView ¶
type ProposalResult ¶
type Proposer ¶
type Proposer interface {
Propose(ctx context.Context, data []byte) (*ProposalResult, error)
}
type Snapshot ¶
Snapshot is an owned export handle from the state machine. Callers are responsible for closing it after WriteTo completes.
type StateMachine ¶
type StateMachine interface {
Apply(data []byte) any
// Snapshot should capture a stable export handle quickly. Expensive snapshot
// serialization belongs in Snapshot.WriteTo, which the engine can run off
// the main raft loop.
Snapshot() (Snapshot, error)
Restore(r io.Reader) error
}
StateMachine is the interface that engine-agnostic state machines must implement. Both the hashicorp and etcd backends use this contract.
type StatusReader ¶
type StatusReader interface {
Status() Status
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package raftenginetest provides a shared conformance test suite for raftengine.Engine implementations.
|
Package raftenginetest provides a shared conformance test suite for raftengine.Engine implementations. |
Click to show internal directories.
Click to hide internal directories.