fsm

package
v4.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 3 Imported by: 5

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
	// StateStopped - process has been terminated.
	StateStopped
	// StateDestroyed State of worker, when no need to allocate new one
	StateDestroyed
	// StateMaxJobsReached State of worker, when it reached executions limit
	StateMaxJobsReached
	// StateErrored - error StateImpl (can't be used).
	StateErrored
	// StateIdleTTLReached - worker idle TTL was reached
	StateIdleTTLReached
	// StateTTLReached - worker TTL was reached
	StateTTLReached
	// StateMaxMemoryReached - worker max memory limit was reached
	StateMaxMemoryReached
	// StateExecTTLReached - worker execution TTL was reached
	StateExecTTLReached
)

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, log *zap.Logger) *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 worker from one state to another

Jump to

Keyboard shortcuts

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