public abstract class MarkerPagingStrategy extends Object implements PagingStrategy
PagingStrategy for APIs which do paging based on a marker provided in the response of each request,
acting as a marker or position inside the stream of results.
Request number 1 will obtain the first page plus a marker embedded in the response. Said marker will be added as a query param in request number 2, which will reply with the next page and a new marker which overwrites the prior one. The process continues until no new marker is provided or the next page comes back empty.
| Constructor and Description |
|---|
MarkerPagingStrategy(String markerParamName)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder |
configureRequest(String baseUri,
org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder,
RestPagingProvider.PagingContext context)
Depending on the paging strategy, different parameters or headers may need to be passed.
|
protected abstract String |
getNextMarker(org.mule.runtime.api.metadata.TypedValue<String> rawPage,
org.mule.runtime.api.util.MultiMap<String,String> headers) |
void |
onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page,
org.mule.runtime.api.metadata.TypedValue<String> rawPage,
org.mule.runtime.api.util.MultiMap<String,String> headers,
RestPagingProvider.PagingContext context)
Invoked each time a page is obtained.
|
public MarkerPagingStrategy(String markerParamName)
markerParamName - the name of the query parameter in which the marker is placed in the requestpublic org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder configureRequest(String baseUri, org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder, RestPagingProvider.PagingContext context)
PagingStrategyconfigureRequest in interface PagingStrategybaseUri - the base uri of the REST API being consumed.requestBuilder - a HttpRequestBuilder.context - the pagination context to allow stopping the pagination mechanism.HttpRequestBuilder configured or a new one.public void onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page, org.mule.runtime.api.metadata.TypedValue<String> rawPage, org.mule.runtime.api.util.MultiMap<String,String> headers, RestPagingProvider.PagingContext context)
PagingStrategyonPage in interface PagingStrategypage - the obtained pagecontext - the pagination context to allow stopping the pagination mechanism.Copyright © 2022. All rights reserved.