MingaEditor.State.Operation (Minga v0.1.0)

Copy Markdown View Source

Serializable semantic feedback for one correlated asynchronous operation.

Summary

Functions

Returns whether the operation can still receive lifecycle updates.

Finishes an active operation and clears active-only queue and cancellation state.

Builds a pending operation with stable identity and deterministic order.

Marks an active operation queued with scheduler-authored metadata.

Records valid domain-authored progress on an active operation.

Marks an active operation running and clears queue metadata.

Returns whether the operation has reached a semantic terminal status.

Types

active_status()

@type active_status() :: :pending | :queued | :running

id()

@type id() :: pos_integer()

kind()

@type kind() ::
  :external_format
  | :git_stage
  | :git_unstage
  | :git_discard
  | :git_stage_all
  | :git_unstage_all
  | :git_commit
  | :lsp_references
  | :lsp_rename

resource()

@type resource() :: String.t()

status()

@type status() :: active_status() | terminal_status()

t()

@type t() :: %MingaEditor.State.Operation{
  cancelable?: boolean(),
  id: id(),
  kind: kind(),
  message: String.t(),
  order: pos_integer(),
  progress: MingaEditor.State.OperationProgress.t() | nil,
  queue: MingaEditor.State.OperationQueue.t() | nil,
  resource: resource(),
  status: status()
}

terminal_status()

@type terminal_status() :: :success | :error | :timeout | :canceled | :stale

Functions

active?(operation)

@spec active?(t()) :: boolean()

Returns whether the operation can still receive lifecycle updates.

finish(operation, status, message)

@spec finish(t(), terminal_status(), String.t()) :: t()

Finishes an active operation and clears active-only queue and cancellation state.

new(id, kind, resource, message, cancelable?, order)

@spec new(id(), kind(), resource(), String.t(), boolean(), pos_integer()) :: t()

Builds a pending operation with stable identity and deterministic order.

queued(operation, message, queue)

@spec queued(t(), String.t(), MingaEditor.State.OperationQueue.t()) :: t()

Marks an active operation queued with scheduler-authored metadata.

report_progress(operation, progress)

@spec report_progress(t(), MingaEditor.State.OperationProgress.t()) :: t()

Records valid domain-authored progress on an active operation.

running(operation, message)

@spec running(t(), String.t()) :: t()

Marks an active operation running and clears queue metadata.

terminal?(operation)

@spec terminal?(t()) :: boolean()

Returns whether the operation has reached a semantic terminal status.