raftflag

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRefresh = errors.New("raft leadership changed, restart worker")

ErrRefresh indicates that the flag's Check result is no longer valid, and a new raftflag.Worker must be started to get a valid result.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a FlagWorker and expose it to clients as a engine.Flag resource.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

Types

type Config

type Config struct {
	Raft *raft.Raft
}

Config holds a raftflag.Worker's dependencies and resources.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be expected to run a raftflag.Worker.

type ManifoldConfig

type ManifoldConfig struct {
	RaftName string

	NewWorker func(Config) (worker.Worker, error)
}

ManifoldConfig holds the information necessary to run a raftflag.Worker in a dependency.Engine.

type Worker

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

Worker implements worker.Worker and util.Flag, representing controller ownership of a model, such that the Flag's validity is tied to the Worker's lifetime.

func (*Worker) Check

func (flag *Worker) Check() bool

Check is part of the util.Flag interface.

Check returns true if the flag indicates that the controller agent is the current raft leader.

The validity of this result is tied to the lifetime of the Worker; once the worker has stopped, no inferences may be drawn from any Check result.

func (*Worker) Kill

func (flag *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Wait

func (flag *Worker) Wait() error

Wait is part of the worker.Worker interface.

Jump to

Keyboard shortcuts

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