Skip to content

lloydkwon/rxjava-http-tail

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rxjava-http-tail

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

About

RxJava-based HTTP log following library

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors