Documentation
¶
Index ¶
- type Engine
- func (e *Engine) AddVoter(ctx context.Context, id string, address string, prevIndex uint64) (uint64, error)
- func (e *Engine) CheckServing(ctx context.Context) error
- func (e *Engine) Close() error
- func (e *Engine) Configuration(ctx context.Context) (raftengine.Configuration, error)
- func (e *Engine) Leader() raftengine.LeaderInfo
- func (e *Engine) LinearizableRead(ctx context.Context) (uint64, error)
- func (e *Engine) Propose(ctx context.Context, data []byte) (*raftengine.ProposalResult, error)
- func (e *Engine) RaftInstance() *raft.Raft
- func (e *Engine) RemoveServer(ctx context.Context, id string, prevIndex uint64) (uint64, error)
- func (e *Engine) State() raftengine.State
- func (e *Engine) Status() raftengine.Status
- func (e *Engine) TransferLeadership(ctx context.Context) error
- func (e *Engine) TransferLeadershipToServer(ctx context.Context, id string, address string) error
- func (e *Engine) VerifyLeader(ctx context.Context) error
- type Factory
- type FactoryConfig
- type MigrationPeer
- type MigrationStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Configuration ¶
func (e *Engine) Configuration(ctx context.Context) (raftengine.Configuration, error)
func (*Engine) Leader ¶
func (e *Engine) Leader() raftengine.LeaderInfo
func (*Engine) LinearizableRead ¶
LinearizableRead blocks until the local FSM has applied all entries up to the current commit index, guaranteeing that a subsequent local read observes the latest committed state (linearizable read). It first ensures that at least one Barrier has been issued since the last leadership transition (Raft §5.4.2), then records CommitIndex, and finally confirms leadership via a quorum check (VerifyLeader) so that a partitioned leader cannot return stale data. When Barrier was executed in this call, VerifyLeader is skipped because Barrier already implies a quorum commit.
func (*Engine) Propose ¶
func (e *Engine) Propose(ctx context.Context, data []byte) (*raftengine.ProposalResult, error)
func (*Engine) RaftInstance ¶
RaftInstance returns the underlying hashicorp raft instance. This is provided for backward compatibility during the engine migration; callers should use the Engine interface instead.
func (*Engine) RemoveServer ¶
func (*Engine) State ¶
func (e *Engine) State() raftengine.State
func (*Engine) Status ¶
func (e *Engine) Status() raftengine.Status
func (*Engine) TransferLeadershipToServer ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory creates hashicorp raft engine instances.
func NewFactory ¶
func NewFactory(cfg FactoryConfig) *Factory
NewFactory returns a Factory with the given hashicorp-specific settings.
func (*Factory) Create ¶
func (f *Factory) Create(cfg raftengine.FactoryConfig) (*raftengine.FactoryResult, error)
func (*Factory) EngineType ¶
type FactoryConfig ¶
type FactoryConfig struct {
CommitTimeout time.Duration
HeartbeatTimeout time.Duration
ElectionTimeout time.Duration
LeaderLeaseTimeout time.Duration
SnapshotRetainCount int
}
FactoryConfig holds hashicorp-specific engine parameters.
type MigrationPeer ¶
MigrationPeer represents a single node in the hashicorp raft cluster.
func ParsePeers ¶
func ParsePeers(raw string) ([]MigrationPeer, error)
ParsePeers parses a comma-separated "id=host:port" list into MigrationPeer values. The format matches the etcd migration tool for consistency.
type MigrationStats ¶
MigrationStats holds summary info about a completed migration.
func MigrateFSMStore ¶
func MigrateFSMStore(storePath string, destDataDir string, peers []MigrationPeer) (*MigrationStats, error)
MigrateFSMStore performs a reverse migration from etcd/raft to hashicorp raft. It reads an FSM PebbleStore snapshot and creates the directory structure that hashicorp/raft expects: a raft.db PebbleStore for log/stable state and a snapshots/ directory containing the FSM snapshot with peer configuration.
The source FSM store (fsm.db) is read-only and shared between both engines; this function only creates the hashicorp-specific artifacts.
IMPORTANT: The source engine must be fully stopped before running this tool. Running it against a live engine may produce an inconsistent snapshot that is missing recently applied entries.