Skip to content

pingles/clj-esper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-esper

A simple Clojure wrapper for Esper: Complex Event Processing.

Esper and NEsper enable rapid development of applications that process large volumes of incoming messages or events. Esper and NEsper filter and analyze events in various ways, and respond to conditions of interest in real-time.

It provides a SQL-like language across a stream of data:

SELECT COUNT(1) as success_count
FROM web_log.win:time(60 seconds)
WHERE status >= 200 AND status < 400
OUTPUT SNAPSHOT EVERY 1 SECONDS

Installing

A snapshot is available on Clojars. This can be added to your leiningen project.clj:

[clj-esper "1.0.0-SNAPSHOT"]

Usage

Esper is organised around events. clj-esper provides a defevent macro that makes it easier to build map event objects for esper (clj-esper uses Esper's Map Event Type).

(defevent TestEvent [a :int b :string])

Having defined an event, the with-esper macro can be used to build the Esper runtime and dispatch events into it.

(def output-events (atom []))
(defn- handler
  [atom]
  (fn [x]
    (swap! atom conj x)))

(def statement "SELECT a, b FROM TestEvent")

(with-esper service {:events #{TestEvent}
                   :uri "/something"}
      (attach-statement statement (handler output-events))
      (trigger-event (new-event TestEvent :a 1 :b "Hello"))

For more examples please see the tests.

TODO

License

Copyright © 2011 Paul Ingles.

Distributed under the GNU General Public License v2.0.

About

Thin layer around Esper event stream processing for Clojure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages