cluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	// Start starts the cluster node
	Start(ctx context.Context) error
	// Stop stops the cluster node
	Stop(ctx context.Context) error
	// GetPeers fetches all the peers of a given node
	GetPeers(ctx context.Context) ([]*goaktpb.Peer, error)
	// PutActor adds an actor meta to the cluster
	PutActor(ctx context.Context, actor *goaktpb.WireActor) error
	// GetActor reads an actor meta from the cluster
	GetActor(ctx context.Context, actorName string) (*goaktpb.WireActor, error)
}

Cluster defines the cluster contract

func New

func New(config *Config) Cluster

New creates an instance of cluster node service

type Config

type Config struct {
	// Logger specifies the logger to use
	Logger log.Logger
	// Host specifies the host address
	Host string
	// Port specifies the port
	Port int32
	// StateDir specifies the cluster state directory
	StateDir string
	// Name specifies the cluster name
	Name string
	// Discovery specifies the discovery engine
	Discovery discovery.Discovery
}

Config represents the cluster configuration

type FSM

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

FSM represents the Finite State Machine of the multi-raft cluster

func NewFSM

func NewFSM(logger log.Logger) *FSM

NewFSM creates a new instance of the FSM

func (*FSM) Apply

func (s *FSM) Apply(data []byte)

Apply committed raft log entry.

func (*FSM) Read

func (s *FSM) Read(actorName string) *goaktpb.WireActor

Read returns the state entry given the key which here is the actor name

func (*FSM) Restore

func (s *FSM) Restore(r io.ReadCloser) error

Restore is used to restore state machine from a snapshot.

func (*FSM) Snapshot

func (s *FSM) Snapshot() (io.ReadCloser, error)

Snapshot is used to write the current state to a snapshot file, on stable storage and compacting the raft logs.

Jump to

Keyboard shortcuts

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