Class AsyncUtils

java.lang.Object
org.a2aproject.sdk.server.util.async.AsyncUtils

public class AsyncUtils extends Object
  • Constructor Details

    • AsyncUtils

      public AsyncUtils()
  • Method Details

    • createTubeConfig

      public static mutiny.zero.TubeConfiguration createTubeConfig()
    • createTubeConfig

      public static mutiny.zero.TubeConfiguration createTubeConfig(int bufferSize)
    • consumer

      public static <T> void consumer(mutiny.zero.TubeConfiguration config, Flow.Publisher<T> source, Function<T,Boolean> nextFunction, Consumer<Throwable> errorConsumer)
    • processor

      public static <T> Flow.Publisher<T> processor(mutiny.zero.TubeConfiguration config, Flow.Publisher<T> source, BiFunction<Consumer<Throwable>,T,Boolean> nextFunction)
    • convertingProcessor

      public static <T, N> Flow.Publisher<N> convertingProcessor(Flow.Publisher<T> source, Function<T,N> converterFunction)
    • insertingProcessor

      @SafeVarargs public static <T> Flow.Publisher<T> insertingProcessor(Flow.Publisher<T> source, T... inserted)
      Creates a publisher that first emits the given items, then emits all items from the source publisher.

      This is useful for prepending initial items to a stream, ensuring they are delivered synchronously when the subscriber subscribes, before any items from the source publisher.

      The inserted items are sent after the source publisher's onSubscribe is called, ensuring proper reactive streams semantics where items are only sent after subscription is established.

      Type Parameters:
      T - the type of items
      Parameters:
      source - the source publisher whose items will be emitted after the inserted items
      inserted - the items to emit first (in order)
      Returns:
      a new publisher that emits inserted items first, then source items