grizzly v0.6.0 Grizzly.Command behaviour View Source
Command is a server managing the overall lifecycle of the execution of a command, from start to completion or timeout.
When starting the execution of a command, the state of the network is checked to see if it is
in one of the allowed states for executing this particular command. The allowed states are listed
in the pre_states
property of the command being started. If the property is absent, the default
allowed states are [:idle]. If the network is not in an allowed state, {:error, :network_busy} is returned.
If the started command has an exec_state
property, the network state is set to its value for the duration
of the execution of the command. If there is none, the network state is unchanged.
If the started command has a post_state
property, the network state is set to it after the command execution
completes or times out. If there is none, the network state is set to :idle.
If the started command has a timeout
property, a timeout is set to its value. If the command does not complete
before the timeout expires, the command's execution is stopped and a {:timeout,
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Link to this section Types
handle_instruction() View Source
t()
View Source
t() :: pid()
t() :: pid()
Link to this section Functions
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
complete(command)
View Source
complete(t()) :: :ok
complete(t()) :: :ok
encode(command)
View Source
encode(t()) :: {:ok, binary()} | {:error, Grizzly.Command.EncodeError.t()}
encode(t()) :: {:ok, binary()} | {:error, Grizzly.Command.EncodeError.t()}
handle_response(command, packet) View Source
start(module, opts)
View Source
start(module(), opts :: keyword()) :: GenServer.on_start()
start(module(), opts :: keyword()) :: GenServer.on_start()
Link to this section Callbacks
encode(command)
View Source
encode(command :: any()) ::
{:ok, binary()} | {:error, Grizzly.Command.EncodeError.t() | any()}
encode(command :: any()) :: {:ok, binary()} | {:error, Grizzly.Command.EncodeError.t() | any()}
handle_response(command, arg2)
View Source
handle_response(command :: any(), Grizzly.Packet.t()) :: handle_instruction()
handle_response(command :: any(), Grizzly.Packet.t()) :: handle_instruction()