feat: skip sending pending payload if URL doesn't match #5834
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the event dispatcher functionality to not send pending requests if the URL is no longer registered as an event observer.
The way pending requests are implemented is that each individual event dispatcher instance checks for pending requests before it sends any new ones. If a node has multiple event observers, this code is ran for each one of them. The first dispatcher is the only one that will actually handle pending requests, if there are any.
Now, the code is updated so that each dispatcher gets pending requests, but then it compares that request to its own URL. If the URL doesn't match, the pending request is skipped.
I think this implementation leaves something to be desired, although I think the ideal change would involve a small refactor of this code. Currently, we're performing IO (O(n)) for each dispatcher for each request, even though we should only ever have pending requests on bootup, and then we should never check again. This would probably be best located in the
EventDispatcher
struct (of which we only have one) instead ofEventObserver
.