hashicorp

package
v0.0.0-...-4edef61 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

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 New

func New(r *raft.Raft) *Engine

func (*Engine) AddVoter

func (e *Engine) AddVoter(ctx context.Context, id string, address string, prevIndex uint64) (uint64, error)

func (*Engine) CheckServing

func (e *Engine) CheckServing(ctx context.Context) error

func (*Engine) Close

func (e *Engine) Close() error

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

func (e *Engine) LinearizableRead(ctx context.Context) (uint64, error)

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

func (e *Engine) RaftInstance() *raft.Raft

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 (e *Engine) RemoveServer(ctx context.Context, id string, prevIndex uint64) (uint64, error)

func (*Engine) State

func (e *Engine) State() raftengine.State

func (*Engine) Status

func (e *Engine) Status() raftengine.Status

func (*Engine) TransferLeadership

func (e *Engine) TransferLeadership(ctx context.Context) error

func (*Engine) TransferLeadershipToServer

func (e *Engine) TransferLeadershipToServer(ctx context.Context, id string, address string) error

func (*Engine) VerifyLeader

func (e *Engine) VerifyLeader(ctx context.Context) error

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 (*Factory) EngineType

func (f *Factory) EngineType() string

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

type MigrationPeer struct {
	ID      string
	Address string
}

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

type MigrationStats struct {
	SnapshotBytes int64
	Peers         int
}

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.

Jump to

Keyboard shortcuts

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