Skip to content
Turn files into asynchronous streams
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
docs
src/vigil
test/vigil
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
project.clj

README.md

Vigil Build Status Clojars Project EPL

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.

For more information, see the documentation.

(require '[vigil.core :as v]
         '[manifold.stream :as s])

;; /foo/bar/baz contains "hello\nworld"
(def stream (v/watch-file "/foo/bar/baz"))

@(s/take! stream)
;; => ("hello" "world")

(spit "/foo/bar/baz" "blah\n" :append true)

;; 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.

For more information, see the documentation.

License

Copyright © 2016 Antoine Kalmbach ane@iki.fi

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

You can’t perform that action at this time.
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.