forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor cache_filter to expect caches to post cb (envoyproxy#36184)
Refactor cache_filter to expect caches to post cb Additional Description: This is a bit of an unintuitive change in that it moves some work from the common class to the plugin, meaning that work will be duplicated. However, there's a good reason for this - if the cache class needs to use a dispatcher to get back onto its own thread, having cache_filter also post means that actions end up being queued in the dispatcher twice. A different possible solution would be to have the cache_filter callbacks only post if the callback comes in on the wrong thread, but there's a wrinkle in that model too - if the callback executes immediately, on the same thread, as was the case with the simple_http_cache, it executes too soon, trying to resume a connection that hasn't yet stopped, which is an error. That, too, could be covered with *another* workaround, either intercepting when that happens and posting the resume, or intercepting when that happens and replacing the resume with returning `Continue` instead, but both of those options make the cache filter itself more complicated (and therefore error prone). Having just one consistent path, where the cache implementation always posts the callback (and never calls it if cancelled), and the cache always performs the callback outside of the initial call's context and on its own thread, is the least complexity, and avoids the performance impact of posting twice, at a cost of a bit more verbosity in the simple cache implementation. This PR also wraps the UpdateHeadersCallback into a declared type, and makes it an `AnyInvocable` instead of a `std::function`, which enforces that callbacks are called only once and that they're moved not copied, avoiding accidental performance drains. Risk Level: Low; WIP filter, existing tests still pass. Testing: Existing tests should be covering all cases. Added tests to enforce that all cache implementations' `LookupContext` correctly posts callback actions, and correctly cancels calling the callback if the context is deleted before the post resolves. Docs Changes: Code-comments only. Release Notes: Maybe? Platform Specific Features: n/a --------- Signed-off-by: Raven Black <[email protected]>
- Loading branch information
1 parent
f575d26
commit decbb66
Showing
16 changed files
with
382 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.