Skip to content
/ sw Public

sw is a very simple implementation of a Sliding Window (from Complex Event Processing)

License

Notifications You must be signed in to change notification settings

paulosuzart/sw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sw

A tiny lib with just a sliding-window reactor (if I can really name it like this) built on top of meltdown.

Usage

; Create an ordinary reactor to serve as the event input for the window.
; Suppose this reactor will handle ecommerce tickets.
(def tickets (mr/create))

; Create the actuall window
(def last-5-secs (sliding-window tickets (match-all) 5000))

; Start pumping data to the reactor
(mr/notify tickets "shirt" 20)

; And register any handler as you would do with a reactor
; Notice this handler is called on every ticker beat, not on 
; every notification on tickets reactor
(on-tick last-5-secs 
  (fn [b]
    (println "Last 5 minutes we sold: " (apply + b))))

(mr/notify tickets "water" 1.25)
(mr/notify tickets ...)

Motivation

To see more details, please read this post. But in summary I wanted a very simple time based sliding mechanism to create a simple dashboard. If one already uses meltdow, it is simple to add this reactor without having to deal with bigger/complex libs or tools.

License

Copyright © 2014 Paulo Suzart

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

WARNING

No battle tested. Use by your own.

About

sw is a very simple implementation of a Sliding Window (from Complex Event Processing)

Resources

License

Stars

Watchers

Forks

Packages

No packages published