states

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ClientStates contains all the states for the Client machine.
	ClientStates = ssC
	// ClientGroups contains all the state groups for the Client machine.
	ClientGroups = sgC
)
View Source
var (

	// WorkerStates contains all the states for the NetMach machine.
	WorkerStates = ssW

	// WorkerGroups contains all the state groups for the NetMach machine.
	WorkerGroups = sgW
)
View Source
var (

	// SupervisorStates contains all the states for the Supervisor machine.
	SupervisorStates = ssS

	// SupervisorGroups contains all the state groups for the Supervisor machine.
	SupervisorGroups = sgS
)
View Source
var BootstrapSchema = ssam.BasicSchema.Merge(

	ssrpc.StateSourceSchema,
	am.Schema{
		cos.WorkerAddr: {},
	})

BootstrapSchema represents all relations and properties of BootstrapStatesDef.

View Source
var (

	// BootstrapStates contains all the states for the Bootstrap machine.
	BootstrapStates = cos
)
View Source
var ClientSchema = ssam.BasicSchema.Merge(

	ssrpc.ConsumerSchema,
	am.Schema{

		ssC.Exception: {},

		ssC.ErrWorker:     {Require: S{Exception}},
		ssC.ErrSupervisor: {Require: S{Exception}},

		ssC.WorkerDisconnected:  {},
		ssC.WorkerConnecting:    {},
		ssC.WorkerConnected:     {},
		ssC.WorkerDisconnecting: {},
		ssC.WorkerReady:         {Remove: S{ssC.WorkerRequested}},
		ssC.Ready: {
			Auto:    true,
			Require: S{ssC.WorkerReady},
		},

		ssC.SuperDisconnected:  {},
		ssC.SuperConnecting:    {},
		ssC.SuperConnected:     {},
		ssC.SuperDisconnecting: {},
		ssC.SuperReady:         {},

		ssC.WorkerRequested: {Require: S{ssC.SuperReady}},
	})

ClientSchema represents all relations and properties of ClientStates.

View Source
var SupervisorSchema = ssam.BasicSchema.Merge(

	ssrpc.StateSourceSchema,
	am.Schema{

		ssS.Start: {Add: S{ssS.PoolStarting}},

		ssS.ErrWorker: {
			Require: S{ssS.Exception},
			Add:     S{ssS.NormalizingPool, ssS.Heartbeat},
		},
		ssS.ErrPool: {
			Require: S{ssS.Exception},
			Remove:  S{ssS.PoolNormalized},
			Add:     S{ssS.NormalizingPool},
		},
		ssS.LocalRpcReady:  {Require: S{ssS.Start}},
		ssS.PublicRpcReady: {Require: S{ssS.Start}},
		ssS.Ready: {Require: S{
			ssS.LocalRpcReady, ssS.PublicRpcReady, ssS.PoolReady}},
		ssS.Heartbeat: {Require: S{ssS.Start}},

		ssS.PoolStarting: {
			Remove: sgS.PoolStatus,
			Add:    S{ssS.NormalizingPool},
		},
		ssS.NormalizingPool: {
			Require: S{ssS.Start},
			Remove:  sgS.PoolNormalized,

			After: S{ssS.ErrWorker},
		},
		ssS.PoolNormalized: {
			Require: S{ssS.Start},
			Remove:  sgS.PoolNormalized,
			Add:     S{ssS.Heartbeat},
		},
		ssS.PoolReady: {
			Require: S{ssS.Start},
			Remove:  sgS.PoolStatus,
			Add:     S{ssS.Heartbeat},
		},
		ssS.WorkersAvailable: {Require: S{ssS.PoolReady}},

		ssS.ListWorkers: {
			Multi:   true,
			Require: S{ssS.Start},
		},
		ssS.SetWorker: {
			Multi:   true,
			Require: S{ssS.Start},
		},

		ssS.ForkWorker: {
			Multi:   true,
			Require: S{ssS.Start},
		},
		ssS.ForkingWorker: {
			Multi:   true,
			Require: S{ssS.Start},
		},
		ssS.WorkerConnected: {
			Multi:   true,
			Require: S{ssS.Start},
		},
		ssS.WorkerForked: {
			Multi:   true,
			Require: S{ssS.Start},
			Add:     S{ssS.Heartbeat},
		},
		ssS.KillWorker:    {Multi: true},
		ssS.KillingWorker: {Multi: true},
		ssS.WorkerKilled: {
			Multi: true,
			Add:   S{ssS.NormalizingPool, ssS.Heartbeat},
		},
		ssS.WorkerReady: {
			Multi:   true,
			Require: S{ssS.Start},
			Add:     S{ssS.PoolReady},
		},
		ssS.WorkerGone: {
			Multi:   true,
			Require: S{ssS.Start},
			Remove:  S{ssS.PoolReady},
		},

		ssS.ClientConnected:    {Multi: true},
		ssS.ClientDisconnected: {Multi: true},

		ssS.ProvideWorker: {
			Multi:   true,
			Require: S{ssS.WorkersAvailable},
		},
		ssS.WorkerIssues: {
			Multi: true,
		},
		ssS.ClientSendPayload: {Multi: true},
		ssS.SuperConnected:    {Multi: true},
		ssS.SuperDisconnected: {Multi: true},

		ssS.SuperSendPayload: {Multi: true},
	})

SupervisorSchema represents all relations and properties of SupervisorStates.

View Source
var WorkerSchema = ssam.BasicSchema.Merge(

	ssrpc.StateSourceSchema,
	am.Schema{

		ssW.ErrWork:        {Require: S{Exception}},
		ssW.ErrWorkTimeout: {Require: S{Exception}},
		ssW.ErrClient:      {Require: S{Exception}},
		ssW.ErrSupervisor:  {Require: S{Exception}},

		ssW.Ready: {Require: S{ssW.LocalRpcReady}},

		ssW.LocalRpcReady:  {Require: S{ssW.Start}},
		ssW.PublicRpcReady: {Require: S{ssW.Start}},

		ssW.RpcReady: {
			Auto:    true,
			Require: S{ssW.LocalRpcReady, ssW.PublicRpcReady},
		},
		ssW.SuperConnected:  {Require: S{ssW.Start}},
		ssW.ServeClient:     {Require: S{ssW.PublicRpcReady}},
		ssW.ClientConnected: {Require: S{ssW.Start}},
		ssW.ClientSendPayload: {
			Require: S{ssW.PublicRpcReady},
		},
		ssW.SuperSendPayload: {
			Require: S{ssW.LocalRpcReady},
		},

		ssW.Idle: {
			Auto:    true,
			Require: S{ssW.Ready},
			Remove:  sgW.WorkStatus,
		},
		ssW.WorkRequested: {
			Require: S{ssW.Ready},
			Remove:  sgW.WorkStatus,
		},
		ssW.Working: {
			Require: S{ssW.Ready},
			Remove:  sgW.WorkStatus,
		},
		ssW.WorkReady: {
			Require: S{ssW.Ready},
			Remove:  sgW.WorkStatus,
		},
	})

WorkerSchema represents all relations and properties of WorkerStates.

Functions

This section is empty.

Types

type BootstrapStatesDef

type BootstrapStatesDef struct {
	*am.StatesBase

	// WorkerAddr - The awaited worker passed its connection details.
	WorkerAddr string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from StateSourceStatesDef
	*ssrpc.StateSourceStatesDef
}

BootstrapStatesDef contains all the states of the Bootstrap state machine. The target state is WorkerAddr, activated by an aRPC client.

type ClientGroupsDef

type ClientGroupsDef struct {
	*ssam.ConnectedGroupsDef
}

ClientGroupsDef contains all the state groups of the Client state machine.

type ClientStatesDef

type ClientStatesDef struct {
	*am.StatesBase

	Exception     string
	ErrWorker     string
	ErrSupervisor string

	WorkerDisconnected  string
	WorkerConnecting    string
	WorkerConnected     string
	WorkerDisconnecting string
	WorkerReady         string
	// Ready - Client is connected to a worker and ready to delegate work and
	// receive payloads.
	Ready string

	SuperDisconnected  string
	SuperConnecting    string
	SuperConnected     string
	SuperDisconnecting string
	// SuperReady - Client is fully connected to the Supervisor.
	SuperReady string
	// WorkerRequested - Client has requested a NetMach from the Supervisor.
	WorkerRequested string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from ConsumerStatesDef
	*ssrpc.ConsumerStatesDef
}

ClientStatesDef contains all the states of the Client state machine.

type SupervisorGroupsDef

type SupervisorGroupsDef struct {
	*ssam.ConnectedGroupsDef

	// PoolStatus are pool's possible statuses, 1 active at a time.
	PoolStatus S
	// Errors list all possible errors of Supervisor.
	Errors S
	// PoolNormalized async
	PoolNormalized S
}

SupervisorGroupsDef contains all the state groups of the Supervisor state machine.

type SupervisorStatesDef

type SupervisorStatesDef struct {
	*am.StatesBase

	ErrWorker string
	ErrPool   string

	LocalRpcReady  string
	PublicRpcReady string
	// Ready - Supervisor is ready to accept new clients.
	Ready string
	// Heartbeat checks the health of the worker pool and network connections.
	Heartbeat string

	// PoolStarting - Supervisor is starting workers to meet the pool definition.
	PoolStarting string
	// NormalizingPool - Supervisor is re-spawning some workers.
	NormalizingPool string
	// PoolNormalized - Supervisor has normalized the pool. Check PoolReady for
	// the result.
	PoolNormalized string
	// PoolReady - Minimum amount of workers are ready.
	PoolReady string
	// TODO all warm warkers ready
	// PoolWarm string
	// WorkersAvailable - There are some idle workers in the pool.
	WorkersAvailable string

	// ListWorkers is a getter returning a list of workers via a channel, with
	// filters.
	ListWorkers string
	// SetWorker is a setter for a worker, which can also delete worker entries.
	SetWorker string
	// ForkWorker - Supervisor starts forking a new worker by creating a new aRPC
	// server.
	ForkWorker string
	// ForkingWorker - Supervisor is forking a new worker.
	ForkingWorker string
	// WorkerForked - New worker connected to bootstrap.
	WorkerConnected string
	// WorkerForked - Supervisor has successfully forked a new worker.
	WorkerForked  string
	KillWorker    string
	KillingWorker string
	WorkerKilled  string
	// WorkerReady - One of the workers become ready.
	WorkerReady string
	// WorkerGone - One of the workers has disconnected.
	WorkerGone string

	// ClientConnected - At least 1 client is connected to the supervisor.
	ClientConnected string
	// ClientDisconnected - 1 Client has disconnected from the supervisor.
	ClientDisconnected string
	// ProvideWorker - Client requests a new worker.
	ProvideWorker string
	// WorkerIssues - Client complains about the worker.
	WorkerIssues string
	// ClientSendPayload - payload delivered to the RPC server with for clients
	// as mutation args.
	ClientSendPayload string

	SuperConnected    string
	SuperDisconnected string
	// SuperSendPayload - payload delivered to the RPC server for supervisors
	// as mutation args.
	SuperSendPayload string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from StateSourceStatesDef
	*ssrpc.StateSourceStatesDef
}

SupervisorStatesDef contains all the states of the Supervisor state machine.

type WorkerGroupsDef

type WorkerGroupsDef struct {

	// WorkStatus represents work-related states, 1 active at a time. This group
	// has to be bound by the implementation, e.g. using Add relation from custom
	// work states.
	WorkStatus S
}

WorkerGroupsDef contains all the state groups of the NetMach state machine.

type WorkerStatesDef

type WorkerStatesDef struct {
	*am.StatesBase

	ErrWork        string
	ErrWorkTimeout string
	ErrClient      string
	ErrSupervisor  string

	// Ready - NetMach is able to perform work.
	Ready string

	// LocalRpcReady - Supervisor RPC server is ready for connections.
	LocalRpcReady string
	// PublicRpcReady - Client RPC server is ready for connections.
	PublicRpcReady string
	// RpcReady - both RPC servers are ready.
	RpcReady string
	// SuperConnected - NetMach is connected to the Supervisor.
	SuperConnected string
	// ServeClient - NetMach is requested to accept a connection from client
	// am.A["id"].
	ServeClient string
	// ClientConnected - NetMach is connected to a client.
	ClientConnected string
	// Send payload to the client
	ClientSendPayload string
	// Send payload to the supervisor
	SuperSendPayload string

	Idle          string
	WorkRequested string
	Working       string
	WorkReady     string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from StateSourceStatesDef
	*ssrpc.StateSourceStatesDef
}

WorkerStatesDef contains all the states of the NetMach state machine.

Jump to

Keyboard shortcuts

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