NotificationStream
NotificationStream owns one observation-only control client attached to a session. It yields tmux notifications in wire order and must be closed. Acquisition requires tmux 3.7 before any control client is started.
Source and package
- Qualified name
-
tmux.Notification Stream - Package
- tmux
- Distribution
- github.com/libtmux/libtmux-go/tmux
- Source
- tmux/notification_stream.go
-
Description#
A stream ends in one of three ways, and none can be resumed. A stream is one tmux client, so a new one is a new client: it starts at tmux's present, with no subscriptions armed, no pane held by PauseAfter, and none of what the old stream had queued or tmux sent in the gap. To recover, close the old stream, read whatever state matters from tmux directly, open another with
Server.OpenNotificationsorSession.OpenNotifications, and Subscribe again.ControlClient.Reconnectis not offered here because it would have to choose between dropping the subscriptions silently and replaying commands, which the package never does.- The caller closed it: reads return an error matching
ErrControlClosedandos.ErrClosed. - tmux ended it, because the server exited or the client fell too far behind: reads return an error matching
ErrControlClosedandErrControlStreamLost, after the notifications queued before the end. - Its backlog filled: reads return a
ControlNotificationOverflowErrormatchingErrControlNotificationOverflowafter the queued prefix. The process is still running and tmux keeps sending, but everything after the overflow is dropped; close the stream.
- The caller closed it: reads return an error matching
Members7#
- Close method Close stops the notification stream. It is safe to call concurrently and more than once.
- CloseContext method CloseContext starts idempotent stream shutdown and waits within ctx. The context bounds only the wait; a later call may resume waiting for shutdown.
- ContinuePane method ContinuePane resumes pane output tmux held after this stream fell behind on it. tmux does not replay what it held, so read the pane to recover that span rather than waiting for it. Resuming a pane tmux never paused does nothing and reports nothing, because tmux answers neither.
- Next method Next returns the next ordered control-mode notification. Concurrent calls are serialized: each notification goes to exactly one call, and a call waiting its turn returns when ctx ends.
- Notifications method Notifications returns
NotificationStream.Nextas a range loop; reads from several iterators or direct calls are serialized. Malformed notifications yield their error and iteration continues; every other error ends the loop after being yielded. - Subscribe method Subscribe asks tmux to evaluate request's format and report it on this stream as a subscription-changed notification, read with
ControlNotification.Subscription. tmux reports the value at its next evaluation, about a second later, and then each time it changes. Arming a name already armed replaces its format. - Unsubscribe method Unsubscribe stops the subscription armed under name. Stopping a name that was never armed does nothing and reports nothing, because tmux answers neither.
Guides#
Pages that discuss NotificationStream.