Core Library0.xAPI reference

Choose documentation 1

pr-173

Current version

pr-173
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

struct libtmux-elixir

Control

A qualified control connection for scoped and managed execution.

Source and package
Qualified name
LibTmux.Control
Module
LibTmux
Package
libtmux
Source
lib/libtmux/control.ex
struct LibTmux.Control

Description

Start with with_connection/2 to own startup and cleanup around a callback. Use execute/3 to obtain a command outcome after wire retirement and record reclamation. Canonical :failed, :skipped and :unknown outcomes remain values, including from bang functions; acknowledgement does not prove external program completion. See the managed control guide.

A successful scope returns {:ok, callback_value} after proven cleanup. LibTmux.Control.ScopeFailure preserves the callback outcome when cleanup fails. LibTmux.Control.ExecutionError carries the operation handle and recovery context for errors after admission.

Starting a connection explicitly attaches to an existing session. The host must qualify effective hooks, aliases and stream writers for its lifetime; lane: :host_qualified declares that work without performing it. Each handle stays pinned to one epoch. Pinning does not authenticate unqualified output or defend against arbitrary writes to internal tables. Local selections never attach, and commands never replay, refresh or change transport.

For independently retained results, use submit/3 and LibTmux.Operation. Awaiting a retained result does not reclaim its record. See the advanced execution guide for explicit ownership. request_close/1 closes write authority for the entire epoch through reserved capacity; it neither proves retirement nor rolls back effects.

Members22 members

Common operations8

  • close/2 function Requests closure and waits for proven retirement of the pinned epoch.
  • execute/3 function Executes one qualified request, returning its result after wire retirement and record reclamation. Repeated successful calls need no manual forget.
  • reconnect/2 function Explicitly obtains the ready epoch, starting a replacement only after retirement.
  • submit/3 function Admits one request and returns its retained operation handle.
  • child_spec/1 function Builds a permanent supervisor child spec without attaching.
  • request_close/1 function Requests whole-epoch closure without claiming an operation or metadata slot.
  • start_link/1 function Starts a linked connection and returns {:ok, root, control}.
  • with_connection/2 function Runs a callback with one connection and owns its native and supervisor cleanup.

Other members14

  • call_option/0: call_option() :: {:timeout, pos_integer()} typealias A positive millisecond budget shared by all stages of one lifecycle or submission call.
  • capabilities/2 function Observes named native tmux prerequisites on this handle's fixed epoch.
  • close!/2 function Waits for retirement or raises the same structured error.
  • connection_status/0: connection_status() :: %{ epoch: reference() | nil, generation: non_neg_integer(), phase: :starting | :ready | :closing | :retired | :unknown, instance: String.t() | nil, terminal: terminal_diagnostic() | nil | :unavailable } typealias A pinned epoch's current phase, identity and terminal evidence; retirement and unknown cleanup are distinct.
  • execute!/3 function Executes and reclaims as in execute/3; raises API/context errors, preserving canonical failures as values.
  • reconnect!/2 function Obtains the ready epoch or raises the same structured error.
  • request_close!/1 function Requests epoch closure or raises the same structured error.
  • scope_option/0: scope_option() :: start_option() | {:cleanup_timeout, 1..950} typealias Startup options plus a separate cleanup allowance of 1..950ms, default 950ms; callback duration has no library timer.
  • start_option/0: start_option() :: {:server, LibTmux.Server.t()} | {:session, {:existing, String.t()}} | {:lane, :host_qualified} | {:timeout, 1..600_000} | {:capacity | :metadata_capacity | :waiter_capacity, 1..256} | {:retention_ms, 1..600_000} typealias Explicit attachment policy and bounded startup settings; capacities count slots and timeouts use milliseconds.
  • status!/1 function Reads pinned connection status or raises the same structured error.
  • status/1 function Reads the pinned epoch's phase, identity and terminal diagnostics without I/O.
  • submit!/3 function Admits a request or raises the same structured error.
  • t/0 typealias A handle pinned to one owner and connection epoch; it never follows a replacement.
  • terminal_diagnostic/0: terminal_diagnostic() :: %{ reason: atom(), phase: atom(), stderr: binary() } typealias An observed close reason, its error phase and at most 8192 captured stderr bytes; not proof of effects or complete stderr.

Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.

Guides

task material

Pages that discuss Control.

Esc
Search in

Type to search.

Reference previewOpen reference