Skip to main content

Module follow

Module follow 

Source
Expand description

Following a growing file, as tail -f does: --follow and t at the table.

The frame scans the file normally, with a slice just above the scan bounding it to complete records (bound). A watcher thread (Follow) checks the size every interval, reads only new bytes, counts the records they complete (Tail) and sends AppEvent::Followed. The app moves the slice in every frame the view holds, so query, filters and sort run over the new rows without rebuilding, then reads the window on screen. A partial last line waits for its newline.

Followed stdin (datui -f -) is spooled to a file by a Spool that keeps copying after the first rows show; that file is followed like any other. An Arrow IPC stream is followed the same way, counting record batches, read by its own scan (stream).

Structs§

Follow
A file being followed: its watcher, and what the view has taken of it. Belongs to the dataset; dropping it stops the watcher.
Marks
Where rows of a followed file start, every so many rows or bytes (MARK_ROWS, MARK_BYTES), and where complete records end, so a deep window reads from the preceding mark. Made by the watcher’s counting pass, at no extra read.
News
One report from a watcher, for the follow named id.
Spool
Stdin copied to a file while it is read, the copy continuing after the first rows show until the stream ends or is stopped. The file is temporary or the one --tee names (kept); --tee - also passes the stream to stdout.
SpoolHandle
The open’s hold on a Spool: the copy stops when the last holder lets go (a follow put down early stops copying), and quitting finishes the file.
Tail
The complete records of a growing delimited or NDJSON file: where they end and how many rows. A partial last record counts once its newline lands.
Tee
The file --tee named.

Enums§

Change
What the watcher found.
Spooled
What standard input was copied to.
Standing
Where the follow stands, as the footer says it.

Constants§

DEFAULT_INTERVAL
How often the watcher checks the file (on Linux, which is notified, the least time between reads), unless [read] follow_interval says otherwise. Appends within one interval are one refresh.

Functions§

age
How long ago, elapsed, as the follow chip says it: in the largest whole unit, padded so the chip keeps its width as the number grows.
bound
Bound lf’s scan of path to its first rows rows: an unbounded scan gets a slice just above it, a bounded one has its bound moved. Frames built on the scan carry it, so all of them follow.
next_tick
When the age of an append made at at next reads differently.
read_through
lf reading the file at path through file, an open handle on it, rather than by its name: the file was deleted, and the handle still reads what it held.
refusal
Why format cannot be followed, or None. Only line-read text and Arrow IPC streams (see followed_stream) can: footer-last files (Parquet, IPC files, Excel) are unreadable until finished, and compressed ones cannot be read mid-way.
refuse_paths
Why paths cannot be followed as options ask, before anything is read: only one local file, or standard input, can be.