ServerMirror
A live copy of one tmux server's sessions, windows, panes and clients, rebuilt whenever tmux announces a change.
Source and package
-
Description#
A control client attached through an anchor session hears what tmux announces. Any announcement, or a
Delivery.Gapin them, starts a freshServer#snapshot()— never a patch of the last one, since an announcement says that something changed, not everything that did. Announcements that arrive while a snapshot is being taken collapse into one more rebuild, and a rebuild that finds nothing different publishes nothing. Each publishedViewcarries an epoch one above the last, counted by this mirror; it is not a number tmux keeps.tmux keeps no history of what it announced. When the control client ends, the mirror finds the anchor session again by its id and attaches through it with a fresh snapshot; if the session has gone, the mirror ends with
TargetGoneException, and if the server has, with the failure that said so. A change tmux does not announce to this client, such as a pane retitled in another session, is seen at the next rebuild, or withinrefreshEverywhen one is given.Thread-safe. One virtual thread per mirror listens and rebuilds;
#close()ends it and the control client with it.Discussed in Getting started
Members9 members#
Other members9 members#
- awaitNewer method Waits for a view newer than
epoch. - cause method Why this mirror ended, when something other than
#close()ended it. - clearNewer method Disarms the callback
#onNewerarmed, if one is armed. - close method Stops listening and detaches the control client. The last view stays readable. Idempotent.
- current method The latest published view.
- isEnded method Whether this mirror has stopped publishing, because it was closed or its anchor has gone.
- onNewer method Arms a one-shot wakeup for when a view newer than
epochis published or the mirror ends. - open method Mirrors the server
anchorbelongs to, listening through a control client attached toanchor. - View struct One published state of the server.