Find a file
patb23 ffa260d971 Merge pull request #3 from patb23/master
* Changed the dependency from com.netflix to io.reactivex. Also handling size based rollover by checking content length against the offset

* Changed the dependency from 'com.netflix' to 'io.reactivex'. Also handling size based rollover by checking content length against the offset
2016-06-07 11:38:25 +03:00
src/main/java/rx Merge pull request #3 from patb23/master 2016-06-07 11:38:25 +03:00
.gitignore release 0.1.0 2013-06-04 20:25:27 +04:00
build.gradle Merge pull request #3 from patb23/master 2016-06-07 11:38:25 +03:00
CODE_OF_CONDUCT.md add unlicense, coc 2015-06-28 15:53:55 +03:00
README.md add unlicense, coc 2015-06-28 15:53:55 +03:00
UNLICENSE add unlicense, coc 2015-06-28 15:53:55 +03:00

rxjava-http-tail unlicense

A RxJava-based port of Net::HTTP::FollowTail to the JVM-land.

This allows you to follow logs like tail -f through HTTP.

Installation

rxjava-http-tail is pushed to Clojars.

So if you're using Leiningen, just add this dependency:

[rxjava-http-tail "0.1.2"]

With Gradle:

repositories {
  maven {
    url "http://clojars.org/repo"
  }
}

dependencies {
  runtime group: 'rxjava-http-tail', name: 'rxjava-http-tail', version: '0.1.2'
}

And Maven:

<repository>
  <id>clojars.org</id>
  <url>http://clojars.org/repo</url>
</repository>
<dependency>
  <groupId>rxjava-http-tail</groupId>
  <artifactId>rxjava-http-tail</artifactId>
  <version>0.1.2</version>
</dependency>

Usage

It can be used from any language on the JVM, but here's an example in Clojure:

(ns example
  (:import rx.HttpTail))

(defn read-offset []
  (Long/parseLong (slurp "offset.txt")))

(defn write-offset [o]
  (spit "offset.txt" o))

(defn on-result [result]
  (let [body (.getBody result)] ; the body is an instance of java.io.InputStream
    (write-offset (.getOffset result))
    (prn (slurp body))
    (.close body)))

(-> (HttpTail. "http://crawl.akrasiac.org/logfile-git" (read-offset) 15000)
    .createObservable
    (.subscribe on-result))
$ echo -n "59690466" > offset.txt
$ lein run -m example

Contributing

Please feel free to submit pull requests! Bugfixes and simple non-breaking improvements will be accepted without any questions :-)

By participating in this project you agree to follow the Contributor Code of Conduct.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.