vigil.core

read-initial

(read-initial file sink & {:keys [initial]})

Reads the content of file, dump it into stream (a stream sink), return how much was read. If :initial is false, don’t dump them into a sink.

read-to-end

(read-to-end path pos)

Reads path to the end starting from pos.

read-update

(read-update stream file old-pos freq)

Reads the content of file from pos and dumps them into stream. Returns the new position where we read, if the stream accepted the content. If the stream did not accept the content after freq milliseconds, it returns the old value, so you can keep calling this function in an idempotent manner.

watch-file

(watch-file file & [initial? buffer-size throttle])

Watches file for changes on disk and returns a Manifold stream representing its content returning sequences of lines. By closing the stream you kill the watch process. The watcher contains a cursor that updates every time content is pushed successfully into the returned stream.

Optional parameters can be specified as follows:

initial? push the initial contents of the file into the stream, defaults to true.
buffer-size the size of the stream buffer, defaults to 1.
throttle wait up to n milliseconds when pushing new content to the stream sink, i.e. how long will the watcher wait for the stream to accept new content. If n milliseconds pass before new content is accepted, the cursor does not advance, defaults to 1000 ms.