scrollback

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	DefaultReadBytes = 256 << 10
	MaxReadBytes     = 1 << 20
)

Read size limits (PROTOCOL.md session.scrollback).

View Source
const SegmentSize = 1 << 20

SegmentSize is the size of one segment file.

Variables

This section is empty.

Functions

This section is empty.

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

func Open(dir string, maxSegs int) (*Store, error)

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) Bounds

func (s *Store) Bounds() (first, end int64)

Bounds returns the oldest retained offset and the stream end.

func (*Store) Close

func (s *Store) Close() error

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

func (s *Store) Range(start, end int64) (data []byte, ok bool)

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.

func (*Store) Read

func (s *Store) Read(before int64, maxBytes int) (data []byte, start, end, first int64, err error)

Read returns the stream bytes [start, end) ending at before (0 = the latest byte), at most maxBytes long (<= 0 → DefaultReadBytes, capped at MaxReadBytes), and the oldest retained offset. start == first means the beginning of the retained stream was reached.

func (*Store) Write

func (s *Store) Write(p []byte) (int, error)

Write appends p to the stream. After the first I/O error the store stops writing (the error is returned once per call) but offsets keep advancing so readers see a gap rather than shifted data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL