Hi ruote mailing list, I have use cases that express the need for timers that would escalate as the deadline approaches. Something in the lines of:
Item is due in 24 hours.
For the first 12 hours, notify every 4 hours
For the next 6 hours, notify every 2 hours
For the next 4 hours, notify every hour
For the last 2 hours, notify every ½ hour
I wanted a syntax in the form of:
action:[start, end]/frequency; action2:[start, end]/frequency; ...
actionN:[start, end]/frequency;
Where <action> is the participant being called, <start> is the first
moment the participant is called, <end> is the last moment the
participant is called, and frequency being the lap time between each
notification within the range of <start> and <end>.
So, in the case of the example above:
[...]
Ruote.define 'our_timers_test' do
sequence do
admin_participant :delay => delay, :our_timers => 'notice:[-24h,
-12h]/4h; important:[-12h, -6h]/2h; urgent[-6h, -2h]/1h;
escalation:[-2h, 0]/30m;'
end
end
[...]
I've took a look at :timers and the `cron`expression and realized our
requirements were somewhere in the middle:
- :timers are an attribute we pass to a participant/subprocess but it
can only write schedule documents up front; and
- `cron` expressions are re-evaluated each time they get executed
`CronExpression::reply -> CronExpression::reschedule` but they are an
expression, not an attribution.
Basically, I'm levering the existing mechanism for timers and I added an
alias around (Ruote::Exp::FlowExpression::consider_timers) .
I've included my current implementation and my current specs in this gist :
https://gist.github.com/jfrioux/d1b945e12edb772f61ed#file-timers_spec-rb-L5
My current set of basic specs is passing fine, but I wanted to know,
since I'm rather a beginner with ruote, if anything in my implementation
seems off or problematic to you, based on your own mileage.
John, is this something that could be merged to Ruote itself or should
it be provided as a gem?
Thank you,
--
Jean-Francois Rioux
Co-founder
Mantor Organization
signature.asc
Description: OpenPGP digital signature
