Documentation
¶
Overview ¶
Package scrollback keeps a session's raw PTY output on disk: append-only segment files of SegmentSize bytes under the session's data directory, oldest segments deleted once the per-session cap is reached. Offsets are positions in the session's whole output stream, so a client can page backwards with `before` even after old segments were dropped.
Writes are plain write(2) calls without fsync: the data is only a convenience copy of what the terminal showed, and readers in the same process see it through the page cache immediately.
Index ¶
Constants ¶
const ( DefaultReadBytes = 256 << 10 MaxReadBytes = 1 << 20 )
Read size limits (PROTOCOL.md session.scrollback).
const SegmentSize = 1 << 20
SegmentSize is the size of one segment file.
Variables ¶
This section is empty.
Functions ¶
func ReadDir ¶ added in v0.17.0
func ReadDir(dir string, before int64, maxBytes int) (data []byte, start, end, first int64, err error)
ReadDir reads the scrollback a store left in dir, as Store.Read would, without opening the store (which would empty dir): the daemon reads the output of a session whose holder has exited this way. A directory without segments is an empty stream; a missing one is os.ErrNotExist.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one session's scrollback. It is safe for concurrent use.
func Open ¶
Open creates (or empties) dir and returns a store keeping at most maxSegs segments (<= 0 means 8, the default of scrollback_session_mib).
func (*Store) Close ¶
Close closes the current segment; later writes are dropped. The files stay for the daemon's retention to delete.
func (*Store) Range ¶ added in v0.3.0
Range returns exactly the stream bytes [start, end), at most MaxReadBytes. ok is false when any of them is no longer retained or was never stored (after a write error), so a caller resuming a client from start falls back to something else rather than send a gap.