raft

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRaft

func NewRaft(raftAddr, raftId, raftDir string, fsm raft.FSM) (*raft.Raft, error)

Types

type Fsm

type Fsm struct {
	// contains filtered or unexported fields
}

func (*Fsm) Apply

func (this *Fsm) Apply(l *raft.Log) interface{}

func (*Fsm) Init

func (this *Fsm) Init()

func (*Fsm) Restore

func (this *Fsm) Restore(reader io.ReadCloser) error

func (*Fsm) Snapshot

func (this *Fsm) Snapshot() (raft.FSMSnapshot, error)

type Raft

type Raft struct {
	*raft.Raft
	*common.ClusterInfo
	// contains filtered or unexported fields
}

func (*Raft) GetHashRing

func (this *Raft) GetHashRing(Id int64) (error, uint32)

func (*Raft) InitRaft

func (this *Raft) InitRaft(info *common.ClusterInfo, Endpoints []string, fsm raft.FSM)

func (*Raft) IsLeader

func (this *Raft) IsLeader() bool

type ShardingFsm

type ShardingFsm struct {
	ShardingSnapshot
	// contains filtered or unexported fields
}

func (*ShardingFsm) Apply

func (this *ShardingFsm) Apply(l *raft.Log) interface{}

func (*ShardingFsm) Get

func (this *ShardingFsm) Get(Id int64) uint32

func (*ShardingFsm) Init

func (this *ShardingFsm) Init(pActor actor.IActor)

func (*ShardingFsm) Restore

func (this *ShardingFsm) Restore(reader io.ReadCloser) error

func (*ShardingFsm) Snapshot

func (this *ShardingFsm) Snapshot() (raft.FSMSnapshot, error)

type ShardingInfo

type ShardingInfo struct {
	Op        string `json:"Op"`
	Id        int64  `json:"Id"`
	ClusterId uint32 `json:"ClusterId"`
}

func (*ShardingInfo) ToByte

func (this *ShardingInfo) ToByte() []byte

type ShardingSnapshot

type ShardingSnapshot struct {
	DataMap map[int64]uint32
	// contains filtered or unexported fields
}

func (*ShardingSnapshot) Persist

func (this *ShardingSnapshot) Persist(sink raft.SnapshotSink) error

func (*ShardingSnapshot) Release

func (this *ShardingSnapshot) Release()

type Snapshot

type Snapshot struct {
	DataMap map[string]string
	// contains filtered or unexported fields
}

func (*Snapshot) Persist

func (this *Snapshot) Persist(sink raft.SnapshotSink) error

-------------------must implent--------------------//

func (*Snapshot) Release

func (this *Snapshot) Release()

Jump to

Keyboard shortcuts

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