fsm

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// StateInactive - no associated process
	StateInactive int64 = iota

	// StateReady - ready for job.
	StateReady

	// StateWorking - working on given payload.
	StateWorking

	// StateInvalid - indicates that WorkerProcess is being disabled and will be removed.
	StateInvalid

	// StateStopping - process is being softly stopped.
	StateStopping

	// StateKilling - process is being forcibly stopped
	StateKilling

	// StateDestroyed State of worker, when no need to allocate new one
	StateDestroyed

	// StateMaxJobsReached State of worker, when it reached executions limit
	StateMaxJobsReached

	// StateStopped - process has been terminated.
	StateStopped

	// StateErrored - error StateImpl (can't be used).
	StateErrored
)

All worker states

Variables

This section is empty.

Functions

This section is empty.

Types

type Fsm

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

Fsm is general https://en.wikipedia.org/wiki/Finite-state_machine to transition between worker states

func NewFSM

func NewFSM(initialState int64) *Fsm

NewFSM returns new FSM implementation based on initial state

func (*Fsm) Compare

func (s *Fsm) Compare(state int64) bool

func (*Fsm) CurrentState

func (s *Fsm) CurrentState() int64

CurrentState (see interface)

func (*Fsm) IsActive

func (s *Fsm) IsActive() bool

IsActive returns true if WorkerProcess not Inactive or Stopped

func (*Fsm) LastUsed

func (s *Fsm) LastUsed() uint64

func (*Fsm) NumExecs

func (s *Fsm) NumExecs() uint64

NumExecs returns number of registered WorkerProcess execs.

func (*Fsm) RegisterExec

func (s *Fsm) RegisterExec()

RegisterExec register new execution atomically

func (*Fsm) SetLastUsed

func (s *Fsm) SetLastUsed(lu uint64)

SetLastUsed Update last used time

func (*Fsm) String

func (s *Fsm) String() string

String returns current StateImpl as string.

func (*Fsm) Transition

func (s *Fsm) Transition(to int64)

Transition moves endure from one state to another

Jump to

Keyboard shortcuts

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