Class CosmosPagedFlux<T>

java.lang.Object
reactor.core.publisher.Flux<T>
com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
com.azure.cosmos.util.CosmosPagedFlux<T>
Type Parameters:
T - The type of elements in a ContinuablePage
All Implemented Interfaces:
org.reactivestreams.Publisher<T>, CorePublisher<T>

public class CosmosPagedFlux<T> extends com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
Cosmos implementation of ContinuablePagedFlux.

This type is a Flux that provides the ability to operate on pages of type FeedResponse and individual items in such pages. This type supports String type continuation tokens, allowing for restarting from a previously-retrieved continuation token.

For more information on the base type, refer ContinuablePagedFlux

See Also:
  • Method Details

    • byPage

      public Flux<FeedResponse<T>> byPage()
      Gets a Flux of FeedResponse starting at the first page.
      Specified by:
      byPage in class com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
      Returns:
      A Flux of FeedResponse.
    • byPage

      public Flux<FeedResponse<T>> byPage(String continuationToken)
      Gets a Flux of FeedResponse beginning at the page identified by the given continuation token.
      Specified by:
      byPage in class com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
      Parameters:
      continuationToken - A continuation token identifying the page to select.
      Returns:
      A Flux of FeedResponse.
    • byPage

      public Flux<FeedResponse<T>> byPage(int preferredPageSize)
      Gets a Flux of FeedResponse starting at the first page requesting each page to contain a number of elements equal to the preferred page size.

      The service may or may not honor the preferred page size therefore the client MUST be prepared to handle pages with different page sizes.

      Specified by:
      byPage in class com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
      Parameters:
      preferredPageSize - The preferred page size.
      Returns:
      A Flux of FeedResponse.
    • byPage

      public Flux<FeedResponse<T>> byPage(String continuationToken, int preferredPageSize)
      Gets a Flux of FeedResponse beginning at the page identified by the given continuation token requesting each page to contain the number of elements equal to the preferred page size.

      The service may or may not honor the preferred page size therefore the client MUST be prepared to handle pages with different page sizes.

      Specified by:
      byPage in class com.azure.core.util.paging.ContinuablePagedFlux<String,T,FeedResponse<T>>
      Parameters:
      continuationToken - A continuation token identifying the page to select.
      preferredPageSize - The preferred page size.
      Returns:
      A Flux of FeedResponse.
    • handle

      public CosmosPagedFlux<T> handle(Consumer<FeedResponse<T>> newFeedResponseConsumer)
      Handle for invoking "side-effects" on each FeedResponse returned by CosmosPagedFlux
      Parameters:
      newFeedResponseConsumer - handler
      Returns:
      CosmosPagedFlux instance with attached handler
    • subscribe

      public void subscribe(CoreSubscriber<? super T> coreSubscriber)
      Subscribe to consume all items of type T in the sequence respectively. This is recommended for most common scenarios. This will seamlessly fetch next page when required and provide with a Flux of items.
      Specified by:
      subscribe in interface CorePublisher<T>
      Specified by:
      subscribe in class Flux<T>
      Parameters:
      coreSubscriber - The subscriber for this CosmosPagedFlux
    • fromList

      public static <T> CosmosPagedFlux<T> fromList(List<T> items, boolean isChangeFeed)
      Creates an instance of a CosmosPagedFlux for mocking purposes or when injecting CosmosPagedFlux instances from a different data source
      Type Parameters:
      T - The type of the items
      Parameters:
      items - - the list of items to be returned
      isChangeFeed - - a flag indicating whether the CosmosPagedFlux will be returned from a change feed API
      Returns:
      an instance of CosmosPagedFlux