Miosa.OpenComputers.Jobs (Miosa v1.0.1)

Copy Markdown View Source

Remote job execution on registered hosts.

Jobs dispatch shell commands to a registered host and return the result once the command completes.

Summary

Functions

Cancel a running job.

Get a specific job by ID.

List jobs for a host.

Run a command on a host and return the completed job.

Stream live output events from a running job (SSE).

Types

result()

@type result() :: {:ok, map()} | {:error, Miosa.Error.t()}

Functions

cancel(client, host_id, job_id)

@spec cancel(Miosa.Client.t(), String.t(), String.t()) :: result()

Cancel a running job.

get(client, host_id, job_id)

@spec get(Miosa.Client.t(), String.t(), String.t()) :: result()

Get a specific job by ID.

list(client, host_id, opts \\ [])

@spec list(Miosa.Client.t(), String.t(), keyword()) :: result()

List jobs for a host.

run(client, host_id, attrs)

@spec run(Miosa.Client.t(), String.t(), map()) :: result()

Run a command on a host and return the completed job.

attrs must include :command. Optional: :args, :env, :cwd, :timeout.

stream(client, host_id, job_id, callback)

@spec stream(Miosa.Client.t(), String.t(), String.t(), function()) ::
  :ok | {:error, Miosa.Error.t()}

Stream live output events from a running job (SSE).

The callback receives %{type: type, data: data} maps. Blocks until done.