How to monitor external resources periodically #277
-
To monitor external resources (like databases) in the controller, e.g., to update the status of a controlled entity accordingly, events need to be requeued periodically. For example, by requeueing events when leaving the handler methods in the controller with 10 seconds delay, we can be sure that a handler is called at least every 10 seconds. However, it seems that this way one is collecting more and more events in the queue of requeued events, which each are requeued again every 10 seconds. For example, if there were updates to the controlled entity at 10:00:01, 10:00:02, ... 10:00:09, then we will have approriate handler methods in the controller called every second forever. What is the best way to requeue events to allow periodical actions without ending in a scenario as described above? Or do I misunderstand the event handling? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
There's a couple of different (fairly easy) options that I see here:
|
Beta Was this translation helpful? Give feedback.
-
In addition to what @erin-allison proposed: What you describe is the idea of https://github.com/smartive/hosted-database-operator/. In https://github.com/smartive/hosted-database-operator/blob/master/src/HostedDatabaseOperator/Controller/HostController.cs#L42-L58 we check the connection on "created", "updated", and "not-modified" events and requeue them with 1 minute delay. Then the status / events are updated on the entity. But: Now if I'm thinking about, you are correct. The requeue mechanism does not check if the given resource (uuid) is already requeued which could lead to such a situation where you pile up requeued entities. |
Beta Was this translation helpful? Give feedback.
There's a couple of different (fairly easy) options that I see here: