Class AsyncPaginator<ReqT,​ProgressParamT>

  • Type Parameters:
    ReqT - The type of the request object
    ProgressParamT - The type of the progression parameter (e.g., page number, offset, cursor)
    All Implemented Interfaces:
    java.util.concurrent.Flow.Publisher<java.net.http.HttpResponse<Blob>>

    public class AsyncPaginator<ReqT,​ProgressParamT>
    extends java.lang.Object
    implements java.util.concurrent.Flow.Publisher<java.net.http.HttpResponse<Blob>>
    A non-blocking generic pagination implementation that handles fetching and publishing paginated data. This class implements the Flow.Publisher interface for asynchronous streaming of paginated responses. It uses a ProgressTrackerStrategy to process pagination metadata from responses and determine when to stop pagination.

    The pagination flow works as follows: 1. subscribe() creates a new subscription for the subscriber 2. The subscription fetches pages asynchronously using CompletableFuture 3. Each response is processed by the progress tracker to update pagination state 4. Pages are emitted to the subscriber until pagination is exhausted or cancelled

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void subscribe​(java.util.concurrent.Flow.Subscriber<? super java.net.http.HttpResponse<Blob>> subscriber)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AsyncPaginator

        public AsyncPaginator​(ReqT initialRequest,
                              ProgressTrackerStrategy<ProgressParamT> progressTracker,
                              java.util.function.BiFunction<ReqT,​ProgressParamT,​ReqT> requestModifier,
                              java.util.function.Function<ReqT,​java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<Blob>>> asyncDataFetcher)
        Creates a new AsyncPaginator instance.
        Parameters:
        initialRequest - The initial request to use for the first page
        progressTracker - The handler that processes pagination metadata from responses
        requestModifier - Function that sets the pagination value in the request
        asyncDataFetcher - Function that fetches the response for a given request asynchronously
    • Method Detail

      • subscribe

        public void subscribe​(java.util.concurrent.Flow.Subscriber<? super java.net.http.HttpResponse<Blob>> subscriber)
        Specified by:
        subscribe in interface java.util.concurrent.Flow.Publisher<ReqT>