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](http://www.nodejs.org), [Werkzeug](http://werkzeug.pocoo.org/), [Sinatra](http://www.sinatrarb.com/) are used to host rulesets written in JavaScript, Python and Ruby respectively.
* Inference state is cached using [Redis](http://www.redis.io), which lets scaling out without giving up performance.
* A web client based on [D3.js](http://www.d3js.org) 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).
####Ruby
```ruby
require 'durable'
Durable.statechart :fraud do
state :start do
to :standby
end
state :standby do
to :metering, when_(m.amount > 100) do
start_timer :velocity, 30
end
end
state :metering do
to :fraud, when_(m.amount > 100, at_least(2)) do
puts "fraud detected"
end
to :standby, when_(timeout :velocity) do
puts "fraud cleared"
end
end
state :fraud
end
Durable.run_all
```
####Python
```python
from durable.lang import *
with statechart('fraud'):
with state('start'):
to('standby')
with state('standby'):
@to('metering')
@when(m.amount > 100)
def start_metering(s):
s.start_timer('velocity', 30)
with state('metering'):
@to('fraud')
@when((m.amount > 100).at_least(2))
def report_fraud(s):
print('fraud detected')
@to('standby')
@when(timeout('velocity'))
def clear_fraud(s):
print('fraud cleared')
state('fraud')
run_all()
```
####JavaScript
```javascript
var d = require('durable');
with (d.statechart('fraud')) {
with (state('start')) {
to('standby');
}
with (state('standby')) {
to('metering').when(m.amount.gt(100), function (s) {
s.startTimer('velocity', 30);
});
}
with (state('metering')) {
to('fraud').when(m.amount.gt(100).atLeast(2), function (s) {
console.log('fraud detected');
});
to('standby').when(timeout('velocity'), function (s) {
console.log('fraud cleared');
});
}
state('fraud');
}
d.runAll();
```
####Visual
<div align="center"><img src="https://raw.github.com/jruizgit/rules/master/statechart.png" width="440px" height="400px" /></div>
#### Resources
To learn more:
* [Setup](https://github.com/jruizgit/rules/blob/master/setup.md)
* [Tutorial](https://github.com/jruizgit/rules/blob/master/tutorial.md)
* [Concepts](https://github.com/jruizgit/rules/blob/master/concepts.md)
Blog:
* [Boosting Performance with C (08/2014)](http://jruizblog.com/2014/08/19/boosting-performance-with-c/)
* [Rete Meets Redis (02/2014)](http://jruizblog.com/2014/02/02/rete-meets-redis/)
* [Inference: From Expert Systems to Cloud Scale Event Processing (01/2014)](http://jruizblog.com/2014/01/27/event-processing/)
=====
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](http://www.nodejs.org), [Werkzeug](http://werkzeug.pocoo.org/), [Sinatra](http://www.sinatrarb.com/) are used to host rulesets written in JavaScript, Python and Ruby respectively.
* Inference state is cached using [Redis](http://www.redis.io), which lets scaling out without giving up performance.
* A web client based on [D3.js](http://www.d3js.org) 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).
####Ruby
```ruby
require 'durable'
Durable.statechart :fraud do
state :start do
to :standby
end
state :standby do
to :metering, when_(m.amount > 100) do
start_timer :velocity, 30
end
end
state :metering do
to :fraud, when_(m.amount > 100, at_least(2)) do
puts "fraud detected"
end
to :standby, when_(timeout :velocity) do
puts "fraud cleared"
end
end
state :fraud
end
Durable.run_all
```
####Python
```python
from durable.lang import *
with statechart('fraud'):
with state('start'):
to('standby')
with state('standby'):
@to('metering')
@when(m.amount > 100)
def start_metering(s):
s.start_timer('velocity', 30)
with state('metering'):
@to('fraud')
@when((m.amount > 100).at_least(2))
def report_fraud(s):
print('fraud detected')
@to('standby')
@when(timeout('velocity'))
def clear_fraud(s):
print('fraud cleared')
state('fraud')
run_all()
```
####JavaScript
```javascript
var d = require('durable');
with (d.statechart('fraud')) {
with (state('start')) {
to('standby');
}
with (state('standby')) {
to('metering').when(m.amount.gt(100), function (s) {
s.startTimer('velocity', 30);
});
}
with (state('metering')) {
to('fraud').when(m.amount.gt(100).atLeast(2), function (s) {
console.log('fraud detected');
});
to('standby').when(timeout('velocity'), function (s) {
console.log('fraud cleared');
});
}
state('fraud');
}
d.runAll();
```
####Visual
<div align="center"><img src="https://raw.github.com/jruizgit/rules/master/statechart.png" width="440px" height="400px" /></div>
#### Resources
To learn more:
* [Setup](https://github.com/jruizgit/rules/blob/master/setup.md)
* [Tutorial](https://github.com/jruizgit/rules/blob/master/tutorial.md)
* [Concepts](https://github.com/jruizgit/rules/blob/master/concepts.md)
Blog:
* [Boosting Performance with C (08/2014)](http://jruizblog.com/2014/08/19/boosting-performance-with-c/)
* [Rete Meets Redis (02/2014)](http://jruizblog.com/2014/02/02/rete-meets-redis/)
* [Inference: From Expert Systems to Cloud Scale Event Processing (01/2014)](http://jruizblog.com/2014/01/27/event-processing/)
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for durable-0.1.4-py2.7-macosx-10.10-intel.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | c215080f1a90ba5cbf21aa5f76723b81d152f1e35151e0999a4e2e067f545d8b |
|
MD5 | e6c583b9e78d16ff7c670be498391cf5 |
|
BLAKE2b-256 | fc3a6409a2598ab306a02378f64b12f29fc5f34c1b640c6eb7a6eaed2e58268a |
Close
Hashes for durable-0.1.4-py2.7-macosx-10.5-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 635d46af2dbea6509ca28ab8b36d22947550b94ea59383131a1b68e83c9089d5 |
|
MD5 | 43bc393e0772bd1cd6ab4d81625eae9d |
|
BLAKE2b-256 | 214da6f2c645981a26e14a5c93fa424c9c4de07e535ec503c7c72517073426dc |