Skip to content

Commit 95986c9

Browse files
authored
Update reference.md
1 parent 5ce9735 commit 95986c9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/js/reference.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ d.runAll();
436436
### Correlated Sequence
437437
Rules can be used to efficiently evaluate sequences of correlated events or facts. The fraud detection rule in the example below shows a pattern of three events: the second event amount being more than 200% the first event amount and the third event amount greater than the average of the other two.
438438

439+
By default a correlated sequences capture distinct messages. In the example below the second event satisfies the second and the third condition, however the event will be captured only for the second condition. Use the `distinct` attribute to disable distinct event or fact correlation.
440+
439441
The `whenAll` label expresses a sequence of events or facts. The assignment operator is used to name events or facts, which can be referenced in subsequent expressions. When referencing events or facts, all properties are available. Complex patterns can be expressed using arithmetic operators.
440442

441443
Arithmetic operators: +, -, *, /
@@ -444,20 +446,21 @@ var d = require('durable');
444446

445447
d.ruleset('risk', function() {
446448
whenAll: {
447-
first = m.amount > 100
449+
first = m.amount > 10
448450
second = m.amount > first.amount * 2
449451
third = m.amount > (first.amount + second.amount) / 2
450452
}
453+
// distinct: true
451454
run: {
452455
console.log('fraud detected -> ' + first.amount);
453456
console.log(' -> ' + second.amount);
454457
console.log(' -> ' + third.amount);
455458
}
456459

457460
whenStart: {
461+
host.post('risk', { amount: 50 });
458462
host.post('risk', { amount: 200 });
459-
host.post('risk', { amount: 500 });
460-
host.post('risk', { amount: 1000 });
463+
host.post('risk', { amount: 251 });
461464
}
462465
});
463466

0 commit comments

Comments
 (0)