Package com.azure.core.http.rest
Class PagedFluxBase<T,P extends PagedResponse<T>>
java.lang.Object
reactor.core.publisher.Flux<T>
com.azure.core.util.paging.ContinuablePagedFlux<C,T,P>
com.azure.core.util.paging.ContinuablePagedFluxCore<String,T,P>
com.azure.core.http.rest.PagedFluxBase<T,P>
- Type Parameters:
T
- The type of items inP
.P
- ThePagedResponse
holding items of typeT
.
- All Implemented Interfaces:
org.reactivestreams.Publisher<T>
,CorePublisher<T>
- Direct Known Subclasses:
PagedFlux
@Deprecated
public class PagedFluxBase<T,P extends PagedResponse<T>>
extends ContinuablePagedFluxCore<String,T,P>
Deprecated.
This class is a flux that can operate on any type that extends
PagedResponse
and also provides the ability to
operate on individual items. When processing the response by page, each response will contain the items in the page
as well as the request details like status code and headers.
Process each item in Flux
To process one item at a time, simply subscribe to this Flux.
pagedFluxBase .log() .subscribe(item -> System.out.println("Processing item with value: " + item), error -> System.err.println("An error occurred: " + error), () -> System.out.println("Processing complete."));
Process one page at a time
To process one page at a time, starting from the beginning, use byPage()
method.
pagedFluxBase .byPage() .log() .subscribe(page -> System.out.printf("Processing page containing item values: %s%n", page.getElements().stream().map(String::valueOf).collect(Collectors.joining(", "))), error -> System.err.println("An error occurred: " + error), () -> System.out.println("Processing complete."));
Process items starting from a continuation token
To process items one page at a time starting from any page associated with a continuation token, use
byPage(String)
.
String continuationToken = getContinuationToken(); pagedFluxBase .byPage(continuationToken) .log() .doOnSubscribe(ignored -> System.out.println( "Subscribed to paged flux processing pages starting from: " + continuationToken)) .subscribe(page -> System.out.printf("Processing page containing item values: %s%n", page.getElements().stream().map(String::valueOf).collect(Collectors.joining(", "))), error -> System.err.println("An error occurred: " + error), () -> System.out.println("Processing complete."));
- See Also:
-
Constructor Summary
ConstructorDescriptionPagedFluxBase
(Supplier<Mono<P>> firstPageRetriever) Deprecated.Creates an instance ofPagedFluxBase
that consists of only a single page.Deprecated.Creates an instance ofPagedFluxBase
. -
Method Summary
Modifier and TypeMethodDescriptionbyPage()
Deprecated.Creates a Flux ofPagedResponse
starting from the first page.Deprecated.Creates a Flux ofPagedResponse
starting from the next page associated with the given continuation token.void
subscribe
(CoreSubscriber<? super T> coreSubscriber) Deprecated.Subscribe to consume all items of typeT
in the sequence respectively.Methods inherited from class com.azure.core.util.paging.ContinuablePagedFluxCore
byPage, byPage, getPageSize
Methods inherited from class com.azure.core.util.paging.ContinuablePagedFlux
getContinuationPredicate
Methods inherited from class reactor.core.publisher.Flux
all, any, as, blockFirst, blockFirst, blockLast, blockLast, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferUntil, bufferUntil, bufferUntilChanged, bufferUntilChanged, bufferUntilChanged, bufferWhen, bufferWhen, bufferWhile, cache, cache, cache, cache, cache, cache, cancelOn, cast, checkpoint, checkpoint, checkpoint, collect, collect, collectList, collectMap, collectMap, collectMap, collectMultimap, collectMultimap, collectMultimap, collectSortedList, collectSortedList, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, concat, concat, concat, concat, concatDelayError, concatDelayError, concatDelayError, concatDelayError, concatMap, concatMap, concatMapDelayError, concatMapDelayError, concatMapDelayError, concatMapIterable, concatMapIterable, concatWith, concatWithValues, contextWrite, contextWrite, count, create, create, defaultIfEmpty, defer, deferContextual, deferWithContext, delayElements, delayElements, delaySequence, delaySequence, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, distinct, distinct, distinct, distinct, distinctUntilChanged, distinctUntilChanged, distinctUntilChanged, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnComplete, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, elapsed, elapsed, elementAt, elementAt, empty, error, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, filterWhen, first, first, firstWithSignal, firstWithSignal, firstWithValue, firstWithValue, flatMap, flatMap, flatMap, flatMap, flatMapDelayError, flatMapIterable, flatMapIterable, flatMapSequential, flatMapSequential, flatMapSequential, flatMapSequentialDelayError, from, fromArray, fromIterable, fromStream, fromStream, generate, generate, generate, getPrefetch, groupBy, groupBy, groupBy, groupBy, groupJoin, handle, hasElement, hasElements, hide, ignoreElements, index, index, interval, interval, interval, interval, join, just, just, last, last, limitRate, limitRate, limitRequest, log, log, log, log, log, log, map, mapNotNull, materialize, merge, merge, merge, merge, merge, merge, mergeComparing, mergeComparing, mergeComparing, mergeComparingDelayError, mergeComparingWith, mergeDelayError, mergeOrdered, mergeOrdered, mergeOrdered, mergeOrderedWith, mergePriority, mergePriority, mergePriority, mergePriorityDelayError, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequentialDelayError, mergeSequentialDelayError, mergeSequentialDelayError, mergeWith, metrics, name, never, next, ofType, onAssembly, onAssembly, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureError, onBackpressureLatest, onErrorComplete, onErrorComplete, onErrorComplete, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onTerminateDetach, or, parallel, parallel, parallel, publish, publish, publish, publish, publishNext, publishOn, publishOn, publishOn, push, push, range, reduce, reduce, reduceWith, repeat, repeat, repeat, repeat, repeatWhen, replay, replay, replay, replay, replay, replay, retry, retry, retryWhen, sample, sample, sampleFirst, sampleFirst, sampleTimeout, sampleTimeout, scan, scan, scanWith, share, shareNext, single, single, singleOrEmpty, skip, skip, skip, skipLast, skipUntil, skipUntilOther, skipWhile, sort, sort, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeOn, subscriberContext, subscriberContext, subscribeWith, switchIfEmpty, switchMap, switchMap, switchOnFirst, switchOnFirst, switchOnNext, switchOnNext, tag, take, take, take, take, takeLast, takeUntil, takeUntilOther, takeWhile, then, then, thenEmpty, thenMany, timed, timed, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toIterable, toIterable, toIterable, toStream, toStream, toString, transform, transformDeferred, transformDeferredContextual, using, using, usingWhen, usingWhen, window, window, window, window, window, window, window, windowTimeout, windowTimeout, windowTimeout, windowTimeout, windowUntil, windowUntil, windowUntil, windowUntilChanged, windowUntilChanged, windowUntilChanged, windowWhen, windowWhile, windowWhile, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith, zipWith, zipWith, zipWithIterable, zipWithIterable
-
Constructor Details
-
PagedFluxBase
Deprecated.Creates an instance ofPagedFluxBase
that consists of only a single page. This constructor takes aSupplier
that return the single page ofT
.Code sample
// A supplier that fetches the first page of data from source/service Supplier<Mono<PagedResponse<Integer>>> firstPageRetrieverFunction = () -> getFirstPage(); PagedFluxBase<Integer, PagedResponse<Integer>> pagedFluxBaseInstance = new PagedFluxBase<>(firstPageRetrieverFunction, nextPageRetriever);
- Parameters:
firstPageRetriever
- Supplier that retrieves the first page.
-
PagedFluxBase
public PagedFluxBase(Supplier<Mono<P>> firstPageRetriever, Function<String, Mono<P>> nextPageRetriever) Deprecated.Creates an instance ofPagedFluxBase
. The constructor takes aSupplier
andFunction
. TheSupplier
returns the first page ofT
, theFunction
retrieves subsequent pages ofT
.Code sample
// A supplier that fetches the first page of data from source/service Supplier<Mono<PagedResponse<Integer>>> firstPageRetriever = () -> getFirstPage(); // A function that fetches subsequent pages of data from source/service given a continuation token Function<String, Mono<PagedResponse<Integer>>> nextPageRetriever = continuationToken -> getNextPage(continuationToken); PagedFluxBase<Integer, PagedResponse<Integer>> pagedFluxBase = new PagedFluxBase<>(firstPageRetriever, nextPageRetriever);
- Parameters:
firstPageRetriever
- Supplier that retrieves the first pagenextPageRetriever
- Function that retrieves the next page given a continuation token
-
-
Method Details
-
byPage
Deprecated.Creates a Flux ofPagedResponse
starting from the first page.Code sample
// Start processing the results from first page pagedFluxBase.byPage() .log() .doOnSubscribe(ignoredVal -> System.out.println( "Subscribed to paged flux processing pages starting from first page")) .subscribe(page -> System.out.printf("Processing page containing item values: %s%n", page.getElements().stream().map(String::valueOf).collect(Collectors.joining(", "))), error -> System.err.println("An error occurred: " + error), () -> System.out.println("Processing complete."));
- Overrides:
byPage
in classContinuablePagedFluxCore<String,
T, P extends PagedResponse<T>> - Returns:
- A
PagedFluxBase
starting from the first page
-
byPage
Deprecated.Creates a Flux ofPagedResponse
starting from the next page associated with the given continuation token. To start from first page, usebyPage()
instead.Code sample
// Start processing the results from a page associated with the continuation token String continuationToken = getContinuationToken(); pagedFluxBase.byPage(continuationToken) .log() .doOnSubscribe(ignoredVal -> System.out.println( "Subscribed to paged flux processing page starting from " + continuationToken)) .subscribe(page -> System.out.printf("Processing page containing item values: %s%n", page.getElements().stream().map(String::valueOf).collect(Collectors.joining(", "))), error -> System.err.println("An error occurred: " + error), () -> System.out.println("Processing complete."));
- Overrides:
byPage
in classContinuablePagedFluxCore<String,
T, P extends PagedResponse<T>> - Parameters:
continuationToken
- The continuation token used to fetch the next page- Returns:
- A
PagedFluxBase
starting from the page associated with the continuation token
-
subscribe
Deprecated.Subscribe to consume all items of typeT
in the sequence respectively. This is recommended for most common scenarios. This will seamlessly fetch next page when required and provide with aFlux
of items.Code sample
pagedFluxBase.subscribe(new BaseSubscriber<Integer>() { @Override protected void hookOnSubscribe(Subscription subscription) { System.out.println("Subscribed to paged flux processing items"); super.hookOnSubscribe(subscription); } @Override protected void hookOnNext(Integer value) { System.out.println("Processing item with value: " + value); } @Override protected void hookOnComplete() { System.out.println("Processing complete."); } });
- Specified by:
subscribe
in interfaceCorePublisher<T>
- Overrides:
subscribe
in classContinuablePagedFluxCore<String,
T, P extends PagedResponse<T>> - Parameters:
coreSubscriber
- The subscriber for thisPagedFluxBase
-
ContinuablePagedFluxCore
.