globalclockupdater

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a global clock updater worker.

func NewTarget

func NewTarget(st *state.State, logger raftleasestore.Logger) raftlease.NotifyTarget

NewTarget is a shim to construct a raftlease.NotifyTarget for testability.

func NewWorker

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

NewWorker returns a new global clock updater worker, using the given configuration.

Types

type Config

type Config struct {
	// NewUpdater returns a new global clock updater.
	NewUpdater func() globalclock.Updater

	// LocalClock is the local wall clock. The times returned must
	// contain a monotonic component (Go 1.9+).
	LocalClock clock.Clock

	// UpdateInterval is the amount of time in between clock updates.
	UpdateInterval time.Duration

	// Logger determines where we write log messages.
	Logger Logger
}

Config contains the configuration for the global clock updater worker.

func (Config) Validate

func (config Config) Validate() error

Validate validates the configuration.

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
	Errorf(string, ...interface{})
	Warningf(string, ...interface{})
}

Logger defines the methods we use from loggo.Logger.

type ManifoldConfig

type ManifoldConfig struct {
	Clock     clock.Clock
	RaftName  string
	StateName string

	FSM            raftlease.ReadOnlyClock
	NewWorker      func(Config) (worker.Worker, error)
	NewTarget      func(*state.State, raftleasestore.Logger) raftlease.NotifyTarget
	UpdateInterval time.Duration
	Logger         Logger
}

ManifoldConfig holds the information necessary to run a GlobalClockUpdater worker in a dependency.Engine.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

type RaftApplier

type RaftApplier interface {
	// Apply applies the input command to Raft's FSM and returns
	// a future that can be used to wait for completion.
	// A non-zero timeout limits the time that we will wait for
	// the operation to be started.
	// Attempting to apply commands to a non-leader node causes
	// an error to be returned.
	Apply(cmd []byte, timeout time.Duration) raft.ApplyFuture

	// State returns the current Raft node state; leader, follower etc.
	State() raft.RaftState
}

RaftApplier describes methods required to coordinate applying commands to a Raft leader node.

type Sleeper

type Sleeper interface {
	Sleep(time.Duration)
}

Sleeper describes functionality for sleeping on the current Goroutine.

type Timer

type Timer interface {
	After(time.Duration) <-chan time.Time
}

Timer describes the ability to receive a notification via channel after some duration has expired.

Jump to

Keyboard shortcuts

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