Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-9721 Add non blocking Publisher for a Cache
  3. ISPN-9811

Implement single response publisher methods

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Major Major
    • 10.0.0.Final
    • None
    • Publisher
    • None

      We need to implement the backend for a method like

         <R> CompletionStage<R> compose(Function<? super Publisher<T>, ? extends CompletionStage<R>> transformer,
               Function<? super Publisher<R>, ? extends CompletionStage<R>> finalizer);
      

      This would allow for all methods that don't require streaming results to be done very easily.

      For example a count method can then just be implemented by doing:

            java.util.function.Function<Publisher<?>, CompletionStage<Long>> transformer = cp ->
                  Flowable.fromPublisher(cp)
                        .count()
                        .to(RxJavaInterop.singleToCompletionStage());
            java.util.function.Function<Publisher<Long>, CompletionStage<Long>> finalizer = results ->
                  Flowable.fromPublisher(results)
                        .reduce((long) 0, Long::sum)
                        .to(RxJavaInterop.singleToCompletionStage());
            return infinispanPublisher.compose(transformer, finalizer);
      

              wburns@redhat.com Will Burns
              wburns@redhat.com Will Burns
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: