-
-
Notifications
You must be signed in to change notification settings - Fork 78
feat: Resource Event De-duplication #394
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
Conversation
Another item of note is this should allow us to fairly easily sort out #340 by using something like https://github.com/amoerie/keyed-semaphores to disallow processing the same resource multiple times at once, without blocking all concurrency. |
Items left for me to finish on here:
|
8f4552d
to
2b3e7d8
Compare
Thank you @erin-allison! I'm thrilled to review the finished work |
Happy to help; I don't actively use the SDK right now but it's a project I'm familiar with that I know I can help contribute to as I have time.
Careful what you wish for 😉 my eyes are set next on #362 and some of the ideas I had mentioned in #355 |
Upon further digging into how |
Oh sh**. Yeah, you're right, the mock controller just assumes that the queue works but this obviously does not work when exactly this queue should be tested. To be honest, I did this kind of confirmation by myself when I did not know how to test certain components. Maybe you have a good idea on how to refactor the mock queue controller and testing in general (ref to #282) to enable such behaviour and use the real queue for testing? |
I have ideas, it'll just take a bit of work as I'll need to basically mock all the services that get injected into it's constructor and wire them up with dummy functionality. |
2b3e7d8
to
4e6a8b2
Compare
@buehler I wouldn't normally cram this much into one PR but in order to test the changes to the event queue, I had to do some other changes, so the thousand-foot overview of what all I did here...
|
Oh hang on, I need to rebase... there's a lot that's been updated. And then I may as well tweak another couple things where I changed my mind. I'd put it back to draft but I can't find if I can. |
When an event for a given resource is added to the queue, all enqueued events (those currently waiting for their "Delay" to elapse) for that resource are unsubscribed from and are thus ignored. For example, if I were to queue a "NotModified" event for a resource with a delay of 10 seconds, then 5 seconds later queue a "Deleted" event, the "Deleted" event would process immediately, and the "NotModified" event would be ignored and not processed. This has no effect on events which are currently in the "UpdateResourceData" or "HandleEvent" steps, as those are already past the de-duplication step. Signed-off-by: Erin Allison <[email protected]>
Signed-off-by: Erin Allison <[email protected]>
…m controller Signed-off-by: Erin Allison <[email protected]>
Signed-off-by: Erin Allison <[email protected]>
Signed-off-by: Erin Allison <[email protected]>
d124a13
to
b6feee2
Compare
Signed-off-by: Erin Allison <[email protected]>
That test works locally... but I guess it was relying on a race condition. Signed-off-by: Erin Allison <[email protected]>
Signed-off-by: Erin Allison <[email protected]>
Signed-off-by: Erin Allison <[email protected]>
Ok, I think this is ready to go; I undid one item that I removed without thinking about it being breaking, so this should have no impact on anything public aside from a couple extra parameters that I exposed on the testing stuff (but there are default values so call signatures should still be valid). |
Thank you @erin-allison! |
FYI: you are not forgotten. I just hadn't had the time to review it 🙈 |
🎉 This PR is included in version 6.4.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
When an event for a given resource is added to the queue, all enqueued events (those currently waiting for their "Delay" to elapse) for that resource are unsubscribed from and are thus ignored.
For example, if I were to queue a "NotModified" event for a resource with a delay of 10 seconds, then 5 seconds later queue a "Deleted" event, the "Deleted" event would process immediately, and the "NotModified" event would be ignored and not processed.
This has no effect on events which are currently in the "UpdateResourceData" or "HandleEvent" steps, as those are already past the de-duplication step.
This would resolve #280, probably #365
Resolves #280
This should also resolve #365 since the cause is a significant difference in the processing pipelines for watcher events vs errored vs requeued events, whereas part of what I do here is to unify that logic (part of what was needed to de-duplicate things).