TermUI.Command.Executor (TermUI v0.2.0)
View SourceExecutes commands asynchronously under a Task.Supervisor.
The executor runs commands in isolated tasks, preventing failures from crashing the runtime. Results are sent back as messages to the originating component.
Usage
# Start the executor (usually in application supervision tree)
{:ok, executor} = Executor.start_link()
# Execute a command
{:ok, command_id} = Executor.execute(executor, command, runtime_pid, component_id)
# Cancel a running command
:ok = Executor.cancel(executor, command_id)
Summary
Functions
Cancels a running command by ID.
Cancels all commands for a component.
Returns a specification to start this module under a supervisor.
Executes a command asynchronously.
Returns the number of currently running commands.
Starts the command executor.
Types
@type t() :: pid()
Functions
Cancels a running command by ID.
Cancels all commands for a component.
Used when a component unmounts.
Returns a specification to start this module under a supervisor.
See Supervisor.
Executes a command asynchronously.
Returns the command ID that can be used for cancellation.
Results are sent to the runtime as {:command_result, component_id, command_id, result}.
@spec running_count(t()) :: non_neg_integer()
Returns the number of currently running commands.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the command executor.
Options
:name- GenServer name (optional):max_concurrent- Maximum concurrent commands (default: 100)