Core LibraryalphaAPI Reference

Choose documentation 1

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

function libtmux-elixir latest

Control.with_connection/2

Runs a callback with one connection and owns its native and supervisor cleanup.

Source and package
Qualified name
LibTmux.Control.with_connection/2
Module
LibTmux
Declared in
Control
Package
libtmux
Source
lib/libtmux/control.ex
with_connection(options, callback) @spec with_connection([scope_option()], (t() -> value)) :: {:ok, value} | {:error, LibTmux.Error.t() | LibTmux.Control.ScopeFailure.t(value)} when value: var

Description#

Takes the explicit server, existing session and host qualification options from start_link/1 . The callback runs in the calling process. Its duration is separate from startup and cleanup_timeout (default 950ms). A dedicated connection owner also requests cleanup when that caller dies.

Returns {:ok, value} after proven connection retirement and Root exit. Cleaned-up exceptions, throws and exits are re-raised with their original stacktrace. If cleanup fails, returns {:error, ScopeFailure} containing the callback's original value or exception and separate cleanup evidence. Startup failures return {:error, Error}; invalid options raise.

The control handle is scoped to the callback. Explicit reconnect is allowed inside it; cleanup permanently fences new epochs and retires the current one. Escaped handles cannot reconnect after the scope. Startup retains start_link/1 's OTP initialization limitation; a timeout can report unknown cleanup while its owner is still unwinding startup. It does not promise a hard native process-exit deadline.

alias LibTmux.Control

Control.with_connection(options, fn control -> Control.execute(control, LibTmux.Control.Request.field("pid")) end)

Type parameters
Parameters

Discussed in Getting started

Esc

Type to search.

Reference preview Open reference