Documentation
¶
Index ¶
- func ResolveStorage(cfg *Config) (engine.PeerStorage, error)
- type AdminApplyFunc
- type ApplyFunc
- type ConfChangeEvent
- type ConfChangeHandler
- type Config
- type Peer
- func (p *Peer) ApplyRegionMetaMirror(meta raftmeta.RegionMeta)
- func (p *Peer) Bootstrap(peers []myraft.Peer) error
- func (p *Peer) Campaign() error
- func (p *Peer) Close() error
- func (p *Peer) Flush() error
- func (p *Peer) ID() uint64
- func (p *Peer) LinearizableRead(ctx context.Context) (uint64, error)
- func (p *Peer) PendingSnapshot() (myraft.Snapshot, bool)
- func (p *Peer) PopPendingSnapshot() (myraft.Snapshot, bool)
- func (p *Peer) Propose(data []byte) error
- func (p *Peer) ProposeAdmin(cmdData []byte) error
- func (p *Peer) ProposeCommand(req *pb.RaftCmdRequest) error
- func (p *Peer) ProposeConfChange(cc raftpb.ConfChangeV2) error
- func (p *Peer) RegionMeta() *raftmeta.RegionMeta
- func (p *Peer) ResendSnapshot(to uint64) bool
- func (p *Peer) Status() myraft.Status
- func (p *Peer) Step(msg myraft.Message) error
- func (p *Peer) Tick() error
- func (p *Peer) TransferLeader(target uint64) error
- func (p *Peer) WaitApplied(ctx context.Context, index uint64) error
- type RaftLogInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveStorage ¶
func ResolveStorage(cfg *Config) (engine.PeerStorage, error)
ResolveStorage chooses the backing log engine (in-memory, on-disk, or WAL).
Types ¶
type AdminApplyFunc ¶
type AdminApplyFunc func(cmd *pb.AdminCommand) error
AdminApplyFunc consumes admin commands (split, merge, etc.).
type ApplyFunc ¶
ApplyFunc consumes committed raft log entries and applies them to the user state machine (LSM, MVCC, etc).
type ConfChangeEvent ¶
type ConfChangeEvent struct {
Peer *Peer
RegionMeta *raftmeta.RegionMeta
ConfChange raftpb.ConfChangeV2
Index uint64
Term uint64
}
ConfChangeEvent captures context for a configuration change entry that has been committed and applied by the raft peer.
type ConfChangeHandler ¶
type ConfChangeHandler func(ConfChangeEvent) error
ConfChangeHandler is invoked whenever a configuration change entry is applied. Returning an error aborts Ready processing so callers can surface failures (for example manifest persistence errors) to the raftstore.
type Config ¶
type Config struct {
RaftConfig myraft.Config
Peers []myraft.Peer
Transport transport.Transport
Apply ApplyFunc
AdminApply AdminApplyFunc
ConfChange ConfChangeHandler
Storage engine.PeerStorage
StorageDir string
GroupID uint64
Region *raftmeta.RegionMeta
LogRetainEntries uint64
MaxInFlightApply uint64
}
Config captures everything required to bootstrap a peer.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer wraps a RawNode with simple storage and apply plumbing.
func NewPeer ¶
NewPeer constructs a peer using the provided configuration. The caller must register the peer with the transport before invoking Bootstrap.
func (*Peer) ApplyRegionMetaMirror ¶ added in v0.7.2
func (p *Peer) ApplyRegionMetaMirror(meta raftmeta.RegionMeta)
ApplyRegionMetaMirror replaces the peer's in-memory region metadata mirror. It exists only so raftstore can synchronize peer-local snapshots after apply/bootstrap has already advanced the store-local region truth. It must not be treated as a consensus state mutation entrypoint.
func (*Peer) Bootstrap ¶
Bootstrap injects the initial configuration into the node. It must be called after the peer has been registered with the transport.
func (*Peer) Close ¶
Close releases resources associated with the peer, including background watermark processors.
func (*Peer) LinearizableRead ¶ added in v0.3.0
LinearizableRead performs a raft ReadIndex round-trip to ensure the peer still holds leadership and returns the corresponding log index. Callers should subsequently wait for that index to be applied before reading state.
func (*Peer) PendingSnapshot ¶
PendingSnapshot returns the snapshot retained for resend without removing it from the queue.
func (*Peer) PopPendingSnapshot ¶
PopPendingSnapshot returns the most recent snapshot recorded during Ready handling, clearing the queue. It returns false when no snapshot is pending.
func (*Peer) ProposeAdmin ¶
ProposeAdmin submits an admin command encoded as pb.AdminCommand payload.
func (*Peer) ProposeCommand ¶ added in v0.2.0
func (p *Peer) ProposeCommand(req *pb.RaftCmdRequest) error
ProposeCommand encodes the provided raft command request and submits it to the raft log.
func (*Peer) ProposeConfChange ¶
func (p *Peer) ProposeConfChange(cc raftpb.ConfChangeV2) error
ProposeConfChange submits a configuration change entry to the raft log.
func (*Peer) RegionMeta ¶
func (p *Peer) RegionMeta() *raftmeta.RegionMeta
RegionMeta returns a clone of the region metadata associated with this peer. It mirrors TinyKV's approach of surfacing region layout through the store for schedulers and debugging endpoints.
func (*Peer) ResendSnapshot ¶
ResendSnapshot attempts to resend the last snapshot destined for the provided peer ID. It returns true when a snapshot message was re-enqueued.
func (*Peer) TransferLeader ¶
TransferLeader requests leadership transfer to the provided peer ID.
type RaftLogInfo ¶
type RaftLogInfo struct {
Pointer raftmeta.RaftLogPointer
LastErr error
Injected bool
}