Detect the absence of an event

Hi,

I try to figure out if it is possible to detect that, within a given amount of time, a certain event was not added to a stream. Say, if I recieve someEvent I want to produce a new event if within 5 seconds no other someEvent is generated. I am looking for a projection like the following:

function NoOtherSomeEventWithin5Seconds(lastEvent) {

emit(“someEventTimeouts”, “someEventTimeout”, { “lastEvent”: lastEvent });

}

fromStream(“MyStream”)

.when({

“someEvent” : function(s, e) {

setTimeout(function() { NoOtherSomeEventWithin5Seconds(e); }, 5000);

}

});

Is there any way of getting someting like the setTimeout Methode? I found an older Thread “First pass on a persistent alarm clock”. I dont understand it completely, but it might point to a solution. Can anyone give advice on this?

Have another service write to a ‘special’ stream every second.

fromStreams([“MyStream”, “MyTimerStream”])

.when({

“$init”: function() {

return { “secondsPassed”: 0 };

},

“time”: function(s, e) {

s.secondsPassed++;

if (s.secondsPassed >= 5) {

emit(…);

s.secondsPassed = 0;

}

},

“someEvent”: functions(s, e) {

s.secondsPassed = 0;

}

});

Thanks for the suggestion. I thought of something like this as well. Would have been nice if it would have been possible to do it all within eventstore, without the need of an external timer service.

But as long as there is no such feature, I can possibly go on with the solution you suggested.

There will not be such a feature (well maybe non-persistent seconds).
The problem is that I really don't want to rebuild crontab :slight_smile: People
want all kind of weird schedules :slight_smile:

Picking up on this thread as I do feel there is a need for a tick (similar to Storm) that developers can use however they want. Relying on an external service to provide the tick is not ideal.