Class PythonPublishers

java.lang.Object
io.micronaut.context.python.PythonPublishers

@Internal public final class PythonPublishers extends Object
Publisher adapters of the Python bridge that keep the reactive context of the subscriber. The Reactor context (a reactive transaction status, the propagated context of an HTTP request) flows from the subscriber up to the source through Reactor subscribers only, so every adapter here is a Reactor operator when Reactor is on the class path; without Reactor no such context exists and the plain Reactive Streams adapters are used.
Since:
5.2.0
  • Method Details

    • map

      public static <T,R> Publisher<R> map(Publisher<T> publisher, Function<T,R> mapper)
      Map the items of a publisher Python code returned. Publishers.map(Publisher, Function) wraps the subscriber in a plain Reactive Streams subscriber, so a source such as Mono.deferContextual or a MANDATORY transaction would see an empty Reactor context; here a Mono stays a Mono and the context of the subscriber is kept.
      Type Parameters:
      T - The source item type
      R - The mapped item type
      Parameters:
      publisher - The source publisher
      mapper - The item mapper
      Returns:
      The mapped publisher
    • deferred

      A publisher that starts a deferred computation (a Python coroutine) when it is first subscribed, in the reactive context of that subscriber, and shares the result with every subscriber: a cancelled subscription does not cancel the shared future, so a later subscriber (a timeout().retry()) still receives the result.
      Parameters:
      starter - Starts the computation in the given context
      Returns:
      The publisher
    • subscribe

      public static void subscribe(Publisher<?> publisher, Subscriber<Object> subscriber, @Nullable PythonReactiveContext reactiveContext)
      Subscribe to a publisher within a reactive context: the propagated context is in scope during the subscription and the Reactor context is written above the subscriber, so the source sees both.
      Parameters:
      publisher - The publisher
      subscriber - The subscriber
      reactiveContext - The reactive context, or null for a plain subscription