reactor-core
reactor-core copied to clipboard
Add ContextPropagation runtime util + captureContext operator
In this PR we introduce a ContextPropagation runtime-detection utility class
as well as a contextCapture() operator. If context-propagation isn't on the
classpath, this operator is NO-OP.
If context-propagation is on the classpath however, the operator will use
it to capture the current context during the subscription phase (at the point
a contextWrite would be effected) and store it in the ContextView visible
from upstream of the operator.
TODO:
- [x]
Monoversion - [x] mention in reference guide? whole section?
- ~marble diagram~
as there is currently no standard marble diagram representation of the Context, we won't provide a marble diagram for now
tentative commit message:
This commit introduces a ContextPropagation runtime-detection utility
class as well as a `contextCapture()` operator.
If context-propagation isn't on the classpath, this operator is NO-OP.
If context-propagation is on the classpath however, the operator will
use it to capture the current context during the subscription phase
(at the point a contextWrite would be effected) and store it in the
ContextView visible from upstream of the operator.
Approved, although I left a few comments - some are minor, for the docs; one I believe to be important for UX, but possible to improve as a follow-up if the logging option is chosen. With additional method, it's probably best to introduce now.
looks like there was no strong consensus on the contextCapture operator being NO-OP if the lib is not on the classpath.
so far all the features in reactor-core that depend on an optional dependency have been exposed that way (eg. Flux#metrics()).
I've fixed the comments on the refguide part.
~Note that this PR is conflicting with #3215, as it adds usage of context-propagation including methods that have seen breaking changes in latest snapshots...~ this is just out-of-sync with M5
I'll need to rebase against current main (which depends on context-propagation M5)