-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add ContextPropagation runtime util + captureContext operator #3145
Conversation
reactor-core/src/main/java/reactor/core/publisher/ContextPropagation.java
Outdated
Show resolved
Hide resolved
as there is currently no standard marble diagram representation of the Context, we won't provide a marble diagram for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some minor comments on the docs.
tentative commit message:
|
* inject them into the {@link Context} | ||
*/ | ||
public final Mono<T> contextCapture() { | ||
if (!ContextPropagation.isContextPropagationAvailable()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remarks as in case of Flux
.
private static final AtomicReference<String> REF1 = new AtomicReference<>(); | ||
private static final AtomicReference<String> REF2 = new AtomicReference<>(); | ||
|
||
//NOTE: no way to currently remove accessors from the ContextRegistry, so we recreate one on each test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 I've fixed the comments on the refguide part.
|
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
I'll need to rebase against current main (which depends on context-propagation M5) |
596dd31
to
22eb92a
Compare
In this PR we introduce a
ContextPropagation
runtime-detection utility classas well as a
contextCapture()
operator. If context-propagation isn't on theclasspath, 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 theContextView
visiblefrom upstream of the operator.
TODO:
Mono
versionmarble diagram