Record Class PythonReactiveContext
java.lang.Object
java.lang.Record
io.micronaut.context.python.PythonReactiveContext
- Record Components:
reactorContext- The Reactorreactor.util.context.Contextof the subscriber, ornullwhen Reactor is not on the class path or the coroutine was started eagerly; typed as an object so the record loads without ReactorpropagatedContext- The propagated context of the subscriber or caller
@Internal
public record PythonReactiveContext(@Nullable Object reactorContext, PropagatedContext propagatedContext)
extends Record
The reactive context a subscriber (or the caller of an eager coroutine) hands to a Python
coroutine: the Reactor context of the subscription (a reactive transaction status lives there)
and the propagated context it carries. The asyncio task keeps it in a
contextvars
variable, so every publisher the coroutine awaits is subscribed within it and every callback of
the task runs in its propagated context, whichever thread or task scheduled the callback.- Since:
- 5.2.0
-
Constructor Summary
ConstructorsConstructorDescriptionPythonReactiveContext(@Nullable Object reactorContext, PropagatedContext propagatedContext) Creates an instance of aPythonReactiveContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.inheriting(PythonReactiveContext enclosing) The context of a coroutine started inside a task: this one, with the Reactor context of the enclosing task when this one has none (an eager start carries the propagated context of the caller only, and a nested coroutine must subscribe within the enclosing transaction).Returns the value of thepropagatedContextrecord component.@Nullable ObjectReturns the value of thereactorContextrecord component.voidRun a callback of the task in the propagated context; called by the asyncio module for everycall_soon/call_latercallback of a task that carries this context.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PythonReactiveContext
Creates an instance of aPythonReactiveContextrecord class.- Parameters:
reactorContext- the value for thereactorContextrecord componentpropagatedContext- the value for thepropagatedContextrecord component
-
-
Method Details
-
inheriting
The context of a coroutine started inside a task: this one, with the Reactor context of the enclosing task when this one has none (an eager start carries the propagated context of the caller only, and a nested coroutine must subscribe within the enclosing transaction). The propagated context of the caller is written into the inherited Reactor context, so a publisher looking it up there (a reactive transaction, tracing) finds the same context the thread runs in rather than the one of the enclosing subscription.- Parameters:
enclosing- The reactive context of the task the coroutine is started from- Returns:
- The context of the new task
-
run
Run a callback of the task in the propagated context; called by the asyncio module for everycall_soon/call_latercallback of a task that carries this context.- Parameters:
callback- The callback
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
reactorContext
Returns the value of thereactorContextrecord component.- Returns:
- the value of the
reactorContextrecord component
-
propagatedContext
Returns the value of thepropagatedContextrecord component.- Returns:
- the value of the
propagatedContextrecord component
-