raft

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoVirtualNodesInPlacementTablesAPILevel = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandType

type CommandType uint8

CommandType is the type of raft command in log entry.

const (
	// MemberUpsert is the command to update or insert new or existing member info.
	MemberUpsert CommandType = 0
	// MemberRemove is the command to remove member from actor host member state.
	MemberRemove CommandType = 1

	// TableDisseminate is the reserved command for dissemination loop.
	TableDisseminate CommandType = 100
)

type DaprHostMember

type DaprHostMember struct {
	// Name is the unique name of Dapr runtime host.
	Name string
	// AppID is Dapr runtime app ID.
	AppID string
	// Entities is the list of Actor Types which this Dapr runtime supports.
	Entities []string

	// UpdatedAt is the last time when this host member info is updated.
	UpdatedAt int64

	// Version of the Actor APIs supported by the Dapr runtime
	APILevel uint32
}

DaprHostMember represents Dapr runtime actor host member which serve actor types.

type DaprHostMemberState

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

DaprHostMemberState is the state to store Dapr runtime host and consistent hashing tables.

func (*DaprHostMemberState) APILevel added in v1.13.0

func (s *DaprHostMemberState) APILevel() uint32

APILevel returns the current API level of the cluster.

func (*DaprHostMemberState) Index

func (s *DaprHostMemberState) Index() uint64

func (*DaprHostMemberState) Members

func (s *DaprHostMemberState) Members() map[string]*DaprHostMember

func (*DaprHostMemberState) TableGeneration

func (s *DaprHostMemberState) TableGeneration() uint64

type DaprHostMemberStateConfig added in v1.13.0

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

type DaprHostMemberStateData added in v1.4.0

type DaprHostMemberStateData struct {
	// Index is the index number of raft log.
	Index uint64
	// Members includes Dapr runtime hosts.
	Members map[string]*DaprHostMember

	// TableGeneration is the generation of hashingTableMap.
	// This is increased whenever hashingTableMap is updated.
	TableGeneration uint64

	// Version of the actor APIs for the cluster
	APILevel uint32
	// contains filtered or unexported fields
}

type FSM

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

FSM implements a finite state machine that is used along with Raft to provide strong consistency. We implement this outside the Server to avoid exposing this outside the package.

func (*FSM) Apply

func (c *FSM) Apply(log *raft.Log) interface{}

Apply log is invoked once a log entry is committed.

func (*FSM) PlacementState

func (c *FSM) PlacementState(withVirtualNodes bool) *v1pb.PlacementTables

PlacementState returns the current placement tables. the withVirtualNodes parameter is here for backwards compatibility and should be removed in 1.15 TODO in v1.15 remove the withVirtualNodes parameter

func (*FSM) Restore

func (c *FSM) Restore(old io.ReadCloser) error

Restore streams in the snapshot and replaces the current state store with a new one based on the snapshot if all goes OK during the restore.

func (*FSM) Snapshot

func (c *FSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot is used to support log compaction. This call should return an FSMSnapshot which can be used to save a point-in-time snapshot of the FSM.

func (*FSM) State

func (c *FSM) State() *DaprHostMemberState

State is used to return a handle to the current state.

type Options added in v1.11.0

type Options struct {
	ID                string
	InMem             bool
	Peers             []PeerInfo
	LogStorePath      string
	Clock             clock.Clock
	ReplicationFactor int64
	MinAPILevel       uint32
	MaxAPILevel       uint32
}

type PeerInfo

type PeerInfo struct {
	ID      string
	Address string
}

PeerInfo represents raft peer node information.

type Server

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

Server is Raft server implementation.

func New

func New(opts Options) *Server

New creates Raft server node.

func (*Server) ApplyCommand

func (s *Server) ApplyCommand(cmdType CommandType, data DaprHostMember) (bool, error)

ApplyCommand applies command log to state machine to upsert or remove members.

func (*Server) FSM

func (s *Server) FSM() *FSM

FSM returns fsm.

func (*Server) IsLeader

func (s *Server) IsLeader() bool

IsLeader returns true if the current node is leader.

func (*Server) Raft

func (s *Server) Raft(ctx context.Context) (*raft.Raft, error)

Raft returns raft node.

func (*Server) StartRaft

func (s *Server) StartRaft(ctx context.Context, sec security.Handler, config *raft.Config) error

StartRaft starts Raft node with Raft protocol configuration. if config is nil, the default config will be used.

Jump to

Keyboard shortcuts

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