You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vigil creates Manifold streams from files. You place a
watcher on a file and the stream produces content as new content is appended to the file.
[vigil "0.1.1"] ; add this to your project.clj
Vigil can be used to monitor logs asynchronously as a stream. If you are creating an event-driven
system, it's easy to create an event filter with Vigil.
Because the produced streams are Manifold streams, which act as a general-purpose compability
layers for asynchronous communication, the file streams can be easily
connected into other
Clojure constructs, such as core.async, lazy sequences,
promises, the list goes on.
(require '[vigil.core :as v]
'[manifold.stream :as s])
;; /foo/bar/baz contains "hello\nworld"
(defstream (v/watch-file"/foo/bar/baz"))
@(s/take! stream)
;; => ("hello" "world")
(spit"/foo/bar/baz""blah\n":appendtrue)
;; the new line has now been pushed to the stream
@(s/take! stream)
;; => ("blah");; shut down the watcher
(s/close! stream)
Usage
The watcher can be stopped at any time by closing the stream. If you don't want to receive the
initial content, pass false to the initial parameter in watch-file. If you delete or truncate
the file, the watcher will stop and the stream will be closed.