-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expire using prioqueue #47
Conversation
fetched from https://github.com/augustohp/Priority-Queue-NodeJS @ afae37d40
Every clock tick, check if the lowest priority item in the priority queue is in the past, and possibly expire it. This prevents events from stalling in the dashboard forever when they don't receive any more updates from riemann because thoses updates don't match the query used.
... instead of a global one, which breaks when there is more than one view per workspace
@@ -109,6 +128,12 @@ var subs = (function() { | |||
var event = JSON.parse(e.data); | |||
event.time = Date.parse(event.time); | |||
clock.advance(event.time); | |||
if (event.ttl > 0) { // only expired events have no TTL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure about that actually...
Can an event with no TTL at all arrive here ? (undefined > 0) == false, so I guess it doesn't really matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Events with a nil TTL should use a default of, say, 60 seconds.
do you think this may cause backwards compatibility issues, e.g. for users who prefer the old behaviour? |
I think this design is preferable. Fixes corner cases! |
So this is basically where I am with this attempt to maintain a pseudo-index inside the dash, to be able to sweep out elements of the display which aren't updated by the websocket stream anymore, for whatever reason. It seems to work feature-wise, but I wouldn't exclude side-effects (I'm not used to writing javascript), and performance has not been taken in account.
I'll add a more couple comments inline where I have doubts and questions.
In any case, many thanks for the guidance @aphyr ! In retrospect, I'm impressed how small this patchset finally is. The code of the dash is really easy to navigate and pleasant to read, congrats !