Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 229f000ec7

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
src
ReadMe.md
pom.xml

ReadMe.md

Kool Streams

Kool Streams is a simple framework for working with aynchronous events and collections. Kool Streams are inspired by a combination of the Reactive Extensions (Rx), Iteratees and various other similar approaches to dealing with concurrency.

Why Kool Stream?

Kool Streams provide a form of asynchronous collection or Event Stream that can be composed and processed like regular collections using the same kind of combinator API folks are familiar with (filter(), flatMap(), map(), fold() etc) but done asynchronously to deal with time delay, network communication, to use threads efficiently and avoid blocking.

API Overview

  • Stream represents a stream of asynchronous events. Its like an asynchronous collection, where events are pushed into a Handler rather than pulled via an iterator.
  • Handler is used to process the events from a stream, through you can just pass a function to handle each next event instead

A Stream is then opened via the open() method either passing in a handler in open(Handler) or by passing in a function to handle even next event via open(fn: (T) -> Unit).

When you open() a Stream you get back a Cursor which can be used to close the stream.

Stream contract

A Stream must only invoke a Handler from one thread at once; so a handler does not need to worry about being thread safe.

The lifecycle of events from a Handler perspective is a stream will invoke

This means that a Handler can choose to close a stream if it knows it has finished processing it. For example if you can use take(n) to limit the size of a stream.

Examples

Create event streams from various things:

Combine streams with Collection-style combinators

Using windows of events for complex event processing types of things

Finally you can pipe the events from a Stream to any Apache Camel Endpoint

Something went wrong with that request. Please try again.