command

package
v0.1.0-alpha4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package command provides a wrapper around the raft log that used strongly-typed commands for communicating state changes across cluster members.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLeader = errors.New("not leader")

ErrNotLeader is the error given when trying to execute a Command on a node that is not the leader.

Functions

func Marshal

func Marshal(cmd Command) ([]byte, error)

Marshal converts a command into its byte representation.

Types

type Command

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

The Command type represents a proto-encoded command that can be applied to a raft cluster.

func New

func New(message proto.Message) Command

New returns a new Command wrapping a proto.Message implementation.

func Unmarshal

func Unmarshal(b []byte) (*Command, error)

Unmarshal converts a byte slice into a Command.

func (Command) Payload

func (cmd Command) Payload() proto.Message

Payload returns the underlying proto.Message implementation describing the Command.

type Executor

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

The Executor type is responsible for executing commands across the raft cluster.

func NewExecutor

func NewExecutor(applier LogApplier, timeout time.Duration) *Executor

NewExecutor returns a new instance of the Executor type that will execute Command instances via the given LogApplier. The timeout is applied across all Command executions.

func (*Executor) Execute

func (ex *Executor) Execute(ctx context.Context, cmd Command) error

Execute the provided command.

type LogApplier

type LogApplier interface {
	ApplyLog(log raft.Log, timeout time.Duration) raft.ApplyFuture
	State() raft.RaftState
}

The LogApplier interface describes types that can apply logs to the raft node.

Jump to

Keyboard shortcuts

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