Raxol.Core.Runtime.Plugins.PluginCommandHandler.Behaviour behaviour (Raxol v0.5.0)

View Source

Defines the behaviour for plugin command handling.

This behaviour is responsible for:

  • Processing command requests
  • Executing commands through plugins
  • Managing command results and error handling
  • Handling command timeouts and errors

Summary

Callbacks

Handles a command request by delegating to the appropriate plugin. Returns an updated state and any necessary side effects.

Updates the command handler state.

Callbacks

handle_command(command_atom, namespace, data, dispatcher_pid, state)

@callback handle_command(
  command_atom :: atom(),
  namespace :: atom(),
  data :: list(),
  dispatcher_pid :: pid(),
  state :: map()
) :: {:ok, map()} | {:error, any()}

Handles a command request by delegating to the appropriate plugin. Returns an updated state and any necessary side effects.

handle_command_error(command_atom, error, dispatcher_pid, state)

@callback handle_command_error(
  command_atom :: atom(),
  error :: any(),
  dispatcher_pid :: pid(),
  state :: map()
) :: {:ok, map()} | {:error, any()}

Handles command errors.

handle_command_result(command_atom, result, dispatcher_pid, state)

@callback handle_command_result(
  command_atom :: atom(),
  result :: any(),
  dispatcher_pid :: pid(),
  state :: map()
) :: {:ok, map()} | {:error, any()}

Handles command results.

handle_command_timeout(command_atom, dispatcher_pid, state)

@callback handle_command_timeout(
  command_atom :: atom(),
  dispatcher_pid :: pid(),
  state :: map()
) :: {:ok, map()} | {:error, any()}

Handles command timeouts.

update_command_state(state, new_state)

@callback update_command_state(
  state :: map(),
  new_state :: map()
) :: map()

Updates the command handler state.