Documentation
¶
Index ¶
- Variables
- func DeriveNodeID(id string) uint64
- 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) 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 GRPCTransport
- func (t *GRPCTransport) Close() error
- func (t *GRPCTransport) Dispatch(ctx context.Context, msg raftpb.Message) error
- func (t *GRPCTransport) DispatchSnapshotSpool(ctx context.Context, msg raftpb.Message, spool *snapshotSpool) error
- func (t *GRPCTransport) Register(server grpc.ServiceRegistrar)
- func (t *GRPCTransport) RemovePeer(nodeID uint64)
- func (t *GRPCTransport) Send(ctx context.Context, req *pb.EtcdRaftMessage) (*pb.EtcdRaftAck, error)
- func (t *GRPCTransport) SendSnapshot(stream pb.EtcdRaft_SendSnapshotServer) error
- func (t *GRPCTransport) SetFSMPayloadOpener(fn func(index uint64) (io.ReadCloser, error))
- func (t *GRPCTransport) SetFSMPayloadReader(fn func(index uint64) ([]byte, error))
- func (t *GRPCTransport) SetFSMSnapDir(dir string)
- func (t *GRPCTransport) SetHandler(handler MessageHandler)
- func (t *GRPCTransport) SetSpoolDir(dir string)
- func (t *GRPCTransport) UpsertPeer(peer Peer)
- type MessageHandler
- type MigrationStats
- type OpenConfig
- type Peer
- type Snapshot
- type StateMachine
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFSMSnapshotFileCRC is returned when the on-disk CRC32C footer does not // match the computed checksum — the .fsm file is corrupt. ErrFSMSnapshotFileCRC = errors.New("fsm snapshot: file CRC32C mismatch (file corrupt)") // ErrFSMSnapshotTokenCRC is returned when the footer and the token CRC // disagree before restore — the metadata is suspect; do not auto-rewrite. ErrFSMSnapshotTokenCRC = errors.New("fsm snapshot: token CRC32C mismatch (metadata corrupt)") // ErrFSMSnapshotNotFound is returned when the expected .fsm file is absent. ErrFSMSnapshotNotFound = errors.New("fsm snapshot: file not found") // ErrFSMSnapshotTooSmall is returned when the file is shorter than the // minimum valid .fsm size (0 or more bytes payload + 4 bytes CRC footer). ErrFSMSnapshotTooSmall = errors.New("fsm snapshot: file too small to contain footer") // ErrFSMSnapshotTokenInvalid is returned when the token bytes cannot be // decoded (wrong length or magic prefix). ErrFSMSnapshotTokenInvalid = errors.New("fsm snapshot: token format invalid") // ErrFSMSnapshotTooLarge is returned when the payload exceeds fsmMaxInMemPayload. // Callers should switch to the streaming path (openFSMSnapshotPayloadReader). ErrFSMSnapshotTooLarge = errors.New("fsm snapshot: payload exceeds maximum in-memory size limit") )
Functions ¶
func DeriveNodeID ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func Open ¶
func Open(ctx context.Context, cfg OpenConfig) (*Engine, error)
Open starts the etcd/raft backend.
Single-node bootstrap waits for local leadership so callers can use the engine immediately. Multi-node startup returns after the local node is running; leadership is established asynchronously through raft transport.
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 (*Engine) Propose ¶
func (e *Engine) Propose(ctx context.Context, data []byte) (*raftengine.ProposalResult, error)
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 etcd raft engine instances.
func NewFactory ¶
func NewFactory(cfg FactoryConfig) *Factory
NewFactory returns a Factory with the given etcd-specific settings.
func (*Factory) Create ¶
func (f *Factory) Create(cfg raftengine.FactoryConfig) (*raftengine.FactoryResult, error)
func (*Factory) EngineType ¶
type FactoryConfig ¶
type FactoryConfig struct {
TickInterval time.Duration
HeartbeatTick int
ElectionTick int
MaxSizePerMsg uint64
MaxInflightMsg int
}
FactoryConfig holds etcd-specific engine parameters.
type GRPCTransport ¶
type GRPCTransport struct {
pb.UnimplementedEtcdRaftServer
// contains filtered or unexported fields
}
func NewGRPCTransport ¶
func NewGRPCTransport(peers []Peer) *GRPCTransport
func (*GRPCTransport) Close ¶
func (t *GRPCTransport) Close() error
func (*GRPCTransport) DispatchSnapshotSpool ¶
func (*GRPCTransport) Register ¶
func (t *GRPCTransport) Register(server grpc.ServiceRegistrar)
func (*GRPCTransport) RemovePeer ¶
func (t *GRPCTransport) RemovePeer(nodeID uint64)
func (*GRPCTransport) Send ¶
func (t *GRPCTransport) Send(ctx context.Context, req *pb.EtcdRaftMessage) (*pb.EtcdRaftAck, error)
func (*GRPCTransport) SendSnapshot ¶
func (t *GRPCTransport) SendSnapshot(stream pb.EtcdRaft_SendSnapshotServer) error
func (*GRPCTransport) SetFSMPayloadOpener ¶
func (t *GRPCTransport) SetFSMPayloadOpener(fn func(index uint64) (io.ReadCloser, error))
SetFSMPayloadOpener registers the callback used by the bridge mode to stream FSM snapshot payloads directly from disk without materialising the full payload in memory.
func (*GRPCTransport) SetFSMPayloadReader ¶
func (t *GRPCTransport) SetFSMPayloadReader(fn func(index uint64) ([]byte, error))
func (*GRPCTransport) SetFSMSnapDir ¶
func (t *GRPCTransport) SetFSMSnapDir(dir string)
func (*GRPCTransport) SetHandler ¶
func (t *GRPCTransport) SetHandler(handler MessageHandler)
func (*GRPCTransport) SetSpoolDir ¶
func (t *GRPCTransport) SetSpoolDir(dir string)
func (*GRPCTransport) UpsertPeer ¶
func (t *GRPCTransport) UpsertPeer(peer Peer)
type MigrationStats ¶
func MigrateFSMStore ¶
func MigrateFSMStore(storePath string, destDataDir string, peers []Peer) (*MigrationStats, error)
type OpenConfig ¶
type Peer ¶
func ParsePeers ¶
type Snapshot ¶
type Snapshot = raftengine.Snapshot
Snapshot is an alias for the shared raftengine.Snapshot interface.
type StateMachine ¶
type StateMachine = raftengine.StateMachine
StateMachine is an alias for the shared raftengine.StateMachine interface.
func AdaptHashicorpFSM ¶
func AdaptHashicorpFSM(fsm raft.FSM) StateMachine
AdaptHashicorpFSM bridges a hashicorp/raft FSM into the etcd-backed engine.