states

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SharedStates contains all the states shared RPC states.
	SharedStates = s

	// SharedGroups contains all the shared state groups for RPC.
	SharedGroups = g
)
View Source
var (

	// ServerStates contains all the states for the Client machine.
	ServerStates = ssS
	// ServerGroups contains all the state groups for the Client machine.
	ServerGroups = sgS
)
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 (

	// MuxStates contains all the states for the Mux machine.
	MuxStates = ssD
	// MuxGroups contains all the state groups for the Mux machine.
	MuxGroups = sgD
)
View Source
var ClientSchema = SharedSchema.Merge(

	ss.ConnectedSchema,

	am.Schema{

		ssC.ErrNetwork: {
			Require: S{am.StateException},
			Remove:  S{ssC.Connecting},
		},

		ssC.Start: {
			Add:    S{ssC.Connecting},
			Remove: S{ssC.ConnRetryFailed},
		},
		ssC.Ready: {
			Auto:    true,
			Require: S{ssC.HandshakeDone},
		},

		ssC.Connected: ss.ConnectedSchema[ss.ConnectedStates.Connected].Extend(
			am.State{
				Remove: S{ssC.RetryingConn},
				Add:    S{ssC.Handshaking},
			}),

		ssC.Handshaking: SharedSchema[s.Handshaking].Extend(am.State{
			Require: S{ssC.Connected},
		}),

		ssC.HandshakeDone: am.StateAdd(
			SharedSchema[ssC.HandshakeDone], am.State{

				Require: S{ssC.Connected},
			}),

		ssC.RetryingCall: {Require: S{ssC.Start}},
		ssC.CallRetryFailed: {
			Remove: S{ssC.RetryingCall},
			Add:    S{ssC.ErrNetwork, am.StateException},
		},
		ssC.RetryingConn:    {Require: S{ssC.Start}},
		ssC.ConnRetryFailed: {Remove: S{ssC.Start}},

		ssC.ServerDelivering: {
			Multi:   true,
			Require: S{ssC.Connected},
		},
		ssC.ServerPayload: {
			Multi:   true,
			Require: S{ssC.Connected},
		},

		ssC.MetricSync: {Multi: true},
	})

ClientSchema represents all relations and properties of ClientStates.

View Source
var ConsumerSchema = am.Schema{
	ssCo.ServerPayload: {Multi: true},
}

ConsumerSchema represents all relations and properties of ConsumerStates.

View Source
var (

	// ConsumerStates contains all the states for the Consumer machine.
	ConsumerStates = ssCo
)
View Source
var MuxSchema = ss.BasicSchema.Merge(am.Schema{
	ssD.Exception: {
		Multi:  true,
		Remove: S{ssS.Ready},
	},

	ssD.Ready: {
		Require: S{ssS.Start},
	},

	ssD.ClientConnected: {
		Multi:   true,
		Require: S{ssD.Start},
	},
	ssD.HasClients:   {Require: S{ssD.Start}},
	ssD.NewServerErr: {},
})

MuxSchema represents all relations and properties of MuxStatesDef.

View Source
var ServerSchema = SharedSchema.Merge(am.Schema{
	ssS.ErrNetwork: {
		Require: S{am.StateException},
		Remove:  S{ssS.ClientConnected},
	},

	ssS.HandshakeDone: SharedSchema[ssS.HandshakeDone].Extend(am.State{
		Require: S{ssS.ClientConnected},

		Remove: S{Exception},
	}),

	ssS.Start: {Add: S{ssS.RpcStarting}},
	ssS.Ready: {
		Auto:    true,
		Require: S{ssS.HandshakeDone, ssS.RpcReady},
	},

	ssS.RpcStarting: {
		Require: S{ssS.Start},
		Remove:  sgS.Rpc,
	},
	ssS.RpcAccepting: {
		Require: S{ssS.Start},
		Remove:  sgS.Rpc,
	},
	ssS.RpcReady: {
		Require: S{ssS.Start},
		Remove:  sgS.Rpc,
	},
	ssS.ClientConnected: {
		Require: S{ssS.RpcReady},
	},

	ssS.MetricSync:      {Multi: true},
	ssS.WebSocketTunnel: {},
})

ServerSchema represents all relations and properties of ClientStates.

View Source
var SharedSchema = ss.BasicSchema.Merge(

	StateSourceSchema,
	am.Schema{

		s.ErrNetwork:        {Require: S{s.Exception}},
		s.ErrNetworkTimeout: {Require: S{s.Exception}},
		s.ErrRpc:            {Require: S{s.Exception}},
		s.ErrDelivery:       {Require: S{s.Exception}},

		s.Handshaking: {
			Require: S{s.Start},
			Remove:  g.Handshake,
		},
		s.HandshakeDone: {
			Require: S{s.Start},
			Remove:  g.Handshake,
		},
	})

SharedSchema represents all relations and properties of StateSourceStates.

View Source
var StateSourceSchema = am.Schema{

	ssSS.ErrOnClient: {Require: S{Exception}},
}

StateSourceSchema represents all relations and properties of StateSourceStates.

View Source
var (

	// StateSourceStates contains all the states for the Network Source machine.
	StateSourceStates = ssSS
)

Functions

This section is empty.

Types

type ClientGroupsDef added in v0.8.0

type ClientGroupsDef struct {
	*SharedGroupsDef
	*ss.ConnectedGroupsDef
}

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

type ClientStatesDef added in v0.8.0

type ClientStatesDef struct {
	// shadow duplicated StatesBase
	*am.StatesBase

	RetryingCall string
	// TODO should be ErrCallRetry, req:Exception
	CallRetryFailed string
	RetryingConn    string
	// TODO should be ErrConnRetry, req:Exception
	ConnRetryFailed string

	// Ready indicates the remote source (worker) is ready to be used.
	Ready         string
	HandshakeDone string

	// ServerDelivering is an optional indication that the server has started a
	// data transmission to the Client.
	ServerDelivering string
	// ServerPayload allows the Consumer to bind his handlers and receive data
	// from the Server via the Client.
	ServerPayload string

	// How many times the client requested a full sync.
	MetricSync string

	// inherit from SharedStatesDef
	*SharedStatesDef
	// inherit from ConnectedStatesDef
	*ss.ConnectedStatesDef
}

ClientStatesDef contains all the states of the Client state machine.

type ConsumerHandlers added in v0.8.0

type ConsumerHandlers interface {
	ServerPayloadState(e *am.Event)
}

ConsumerHandlers is the required interface for Consumer's state handlers.

type ConsumerStatesDef added in v0.8.0

type ConsumerStatesDef struct {
	*am.StatesBase
	Exception string

	// ServerPayload RPC server delivers the requested payload to the Client.
	ServerPayload string
}

ConsumerStatesDef contains all the states of the Consumer state machine.

type MuxGroupsDef added in v0.17.1

type MuxGroupsDef struct {
}

MuxGroupsDef contains all the state groups of the Mux state machine.

type MuxStatesDef added in v0.8.0

type MuxStatesDef struct {
	// shadow duplicated StatesBase
	*am.StatesBase

	// Ready - mux is ready to accept new clients.
	Ready string

	// stateless event
	ClientConnected string
	HasClients      string
	// NewServerErr - new server returned an error. The mux is still running.
	// TODO refac
	NewServerErr string

	// inherit from BasicStatesDef
	*ss.BasicStatesDef
}

MuxStatesDef contains all the states of the Mux state machine. The target state is PortInfo, activated by an aRPC client.

type ServerGroupsDef added in v0.8.0

type ServerGroupsDef struct {
	*SharedGroupsDef

	// Rpc is a group for RPC ready states.
	Rpc S
}

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

type ServerStatesDef added in v0.8.0

type ServerStatesDef struct {
	*am.StatesBase

	// Ready - Client is fully connected to the server.
	Ready string

	// Starting listening
	RpcStarting string
	// setting up RPC accepting
	RpcAccepting string
	// TODO RpcAcceptingJson for JSON-RPC over WS
	// RPC is accepting or has accepted connections
	RpcReady string

	// RPC client connected (technically)
	ClientConnected string
	// RPC client fully usable
	HandshakeDone string

	// How many times the client requested a full sync.
	MetricSync string
	// TCP tunneled over websocket
	WebSocketTunnel string

	// inherit from SharedStatesDef
	*SharedStatesDef
}

ServerStatesDef contains all the states of the Client state machine.

type SharedGroupsDef added in v0.8.0

type SharedGroupsDef struct {

	// Work represents work-related states, 1 active at a time.
	Handshake S
}

SharedGroupsDef contains all the state groups of the Shared state machine.

type SharedStatesDef added in v0.8.0

type SharedStatesDef struct {
	*am.StatesBase

	ErrNetworkTimeout string
	ErrRpc            string
	ErrDelivery       string

	HandshakeDone string
	Handshaking   string

	// inherit from BasicStatesDef
	*ss.BasicStatesDef
	// inherit from rpc/StateSourceStatesDef (for REPL)
	*StateSourceStatesDef
}

SharedStatesDef contains all the states of the Shared state machine.

type StateSourceStatesDef added in v0.18.0

type StateSourceStatesDef struct {
	*am.StatesBase

	// ErrOnClient indicates an error added on the Network Machine.
	ErrOnClient string
}

StateSourceStatesDef contains all the states of the Network Source state machine.

Jump to

Keyboard shortcuts

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