Skip to main content

Durable Rules Engine

Project description

Durable Rules
Durable Rules is a polyglot micro-framework for real-time, consistent and scalable coordination of events. With Durable Rules you can track and analyze information about things that happen (events) by combining data from multiple sources to infer more complicated circumstances.

A forward chaining algorithm (A.K.A. Rete) is used to evaluate massive streams of data. A simple, yet powerful meta-liguistic abstraction lets you define simple and complex rulesets, such as flowcharts, statecharts, nested statecharts, paralel and time driven flows.

The Durable Rules core engine is implemented in C, which enables ultra fast rule evaluation and inference as well as muti-language support. Durable Rules relies on state of the art technologies:

* [Node.js](, [Werkzeug](, [Sinatra]( are used to host rulesets written in JavaScript, Python and Ruby respectively.
* Inference state is cached using [Redis](, which lets scaling out without giving up performance.
* A web client based on [D3.js]( provides powerful data visualization and test tools.

Below is an example on how easy it is to define a real-time fraud detection rule (three purchases over $100 within a 30 second interval).

require 'durable'

Durable.statechart :fraud do
state :start do
to :standby
state :standby do
to :metering, when_(m.amount > 100) do
start_timer :velocity, 30
state :metering do
to :fraud, when_(m.amount > 100, at_least(2)) do
puts "fraud detected"
to :standby, when_(timeout :velocity) do
puts "fraud cleared"
state :fraud

from durable.lang import *

with statechart('fraud'):
with state('start'):

with state('standby'):
@when(m.amount > 100)
def start_metering(s):
s.start_timer('velocity', 30)

with state('metering'):
@when((m.amount > 100).at_least(2))
def report_fraud(s):
print('fraud detected')

def clear_fraud(s):
print('fraud cleared')


var d = require('durable');

with (d.statechart('fraud')) {
with (state('start')) {
with (state('standby')) {
to('metering').when(, function (s) {
s.startTimer('velocity', 30);
with (state('metering')) {
to('fraud').when(, function (s) {
console.log('fraud detected');
to('standby').when(timeout('velocity'), function (s) {
console.log('fraud cleared');

<div align="center"><img src="" width="440px" height="400px" /></div>

#### Resources
To learn more:
* [Setup](
* [Tutorial](
* [Concepts](

* [Boosting Performance with C (08/2014)](
* [Rete Meets Redis (02/2014)](
* [Inference: From Expert Systems to Cloud Scale Event Processing (01/2014)](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

durable-0.1.4-py2.7-macosx-10.10-intel.egg (84.2 kB view hashes)

Uploaded 2 7

durable-0.1.4-py2.7-macosx-10.5-x86_64.egg (81.1 kB view hashes)

Uploaded 2 7

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page