A JavaScript library for coding complex event processing reactively
CEP.js is a JavaScript library for coding complex event processing (CEP) reactively. It works as a big adapter, accepting different reactive libraries to express event processing operations while leveraging a sintax model close to the widely used ReactiveX for JavaScript (RxJS). Besides usual RxJS operations regarding stream manipulation, it also bundles common CEP operations revolving around filtering, transformation, and specially pattern detection.
Advantages:
✔️ A library: offers greater flexibility as well as low latency (processing in-place) and lower overhead
✔️ Pattern options: there are currently many supported patterns covering areas like logical, trends, threshold
✔️ Adaptable: CEP.js alredy works with two reactive libraries to drive its operations
✔️ Microservices-affinity: the library can be easily integrated in a microservices environment
Before continuing with installation, one must choose among the supported reactive libraries. In order to better manage those reactive libraries, they are organized in distinct packages bundling all necessary dependencies. See the reactive libraries file to find more information on the reactive libraries and the respective packages.
npm:
# either
npm install --save cepjs-core cepjs-rx
# or
npm install --save cepjs-core cepjs-most
browser:
<script src="...path_to_cepjs-core/dist/cepjsCore.min.js"></script>
<!-- In case RxJS will be used -->
<script src="...path_to_cepjs-rx/dist/cepjsRx.min.js"></script>
<!-- In case Most.js will be used instead -->
<script src="...path_to_cepjs-most/dist/cepjsMost.min.js"></script>
The packages, available through npm, already include distribution files (for browser usage) under the dist
folder. Alternatively, one can execute the command npm run build
within the root folder of any package to build the code and generate the distribution files.
If needed, a ES5 build can be generated for every package. Just run the script npm run build:es5
inside one of the packages. After that, the built file will be available in the dist.es5
folder.
Requeries the execution of
npm install
to intall the dev dependencies before the building process.
The first step to take is to import the core package. The package exports a factory function expecting to be passed in any of the custom reactive packages chose during installation. All of the operations are then available under the same namespace. The following snippets exemplify those steps.
const coreFactory = require('cepjs-core'); //factory function
const { merge, fromEvent, tumblingTimeWindow, all, EventType } = coreFactory(require('cepjs-rx')); //access some operations
const coreFactory = cepjsCore; //factory function
const { merge, fromEvent, tumblingTimeWindow, all, EventType } = coreFactory(cepjsRx); //access some operations
- Example
- Unit tests
- Implement more patterns
- Add support to pattern policies
We highly appretiate contributions but before doing that, take a look into the contribution guidelines.
Most of the implemented operations are based on the following important work:
- Etzion, O., & Niblett, P. (2011). Event processing in action. Manning.
CEP.js is available under the MIT license. See the LICENSE file for more info.