T
- the TypeReference
of the response type from a polling call, or BinaryData if raw response body
should be keptU
- the TypeReference
of the final result object to deserialize into, or BinaryData if raw response
body should be keptpublic interface PollingStrategy<T,U>
The methods in the polling strategy will be invoked from the PollerFlux
. The
order of the invocations is:
PollingStrategy.canPoll(Response)
- exits if returns falsePollingStrategy.onInitialResponse(Response, PollingContext, TypeReference)
- immediately after
PollingStrategy.canPoll(Response)
returns truePollingStrategy.poll(PollingContext, TypeReference)
- invoked after each polling interval, if the last polling
response indicates an "In Progress" status. Returns a PollResponse
with the latest statusPollingStrategy.getResult(PollingContext, TypeReference)
- invoked when the last polling response indicates a
"Successfully Completed" status. Returns the final result of the given typeAsyncPollResponse
or SyncPoller
, the
PollingStrategy.cancel(PollingContext, PollResponse)
method will be invoked. If the strategy doesn't support cancellation,
an error will be returned.
Users are not expected to provide their own implementation of this interface. Built-in polling strategies in this library and other client libraries are often sufficient for handling polling in most long running operations in Azure. When there are special scenarios, built-in polling strategies can be inherited and select methods can be overridden to accomplish the polling requirements, without writing an entire polling strategy from scratch.
Modifier and Type | Method and Description |
---|---|
default Mono<T> |
cancel(PollingContext<T> pollingContext,
PollResponse<T> initialResponse)
Cancels the long running operation if service supports cancellation.
|
Mono<Boolean> |
canPoll(Response<?> initialResponse)
Checks if this strategy is able to handle polling for this long running operation based on the information in
the initial response.
|
Mono<U> |
getResult(PollingContext<T> pollingContext,
TypeReference<U> resultType)
Parses the response from the final GET call into the result type of the long running operation.
|
Mono<PollResponse<T>> |
onInitialResponse(Response<?> response,
PollingContext<T> pollingContext,
TypeReference<T> pollResponseType)
Parses the initial response into a
LongRunningOperationStatus , and stores information useful for polling
in the PollingContext . |
Mono<PollResponse<T>> |
poll(PollingContext<T> pollingContext,
TypeReference<T> pollResponseType)
Parses the response from the polling URL into a
PollResponse , and stores information
useful for further polling and final response in the PollingContext . |
Mono<Boolean> canPoll(Response<?> initialResponse)
initialResponse
- the response from the initial method call to activate the long running operationMono<PollResponse<T>> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
LongRunningOperationStatus
, and stores information useful for polling
in the PollingContext
. If the result is anything other than LongRunningOperationStatus.IN_PROGRESS
,
the long running operation will be terminated and none of the other methods will be invoked.response
- the response from the initial method call to activate the long running operationpollingContext
- the PollingContext
for the current polling operationpollResponseType
- the TypeReference
of the response type from a polling call, or BinaryData if raw
response body should be kept. This should match the generic parameter U
.Mono<PollResponse<T>> poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
PollResponse
, and stores information
useful for further polling and final response in the PollingContext
. The result must have the
LongRunningOperationStatus
specified, and the entire polling response content as a BinaryData
.pollingContext
- the PollingContext
for the current polling operationpollResponseType
- the TypeReference
of the response type from a polling call, or BinaryData if raw
response body should be kept. This should match the generic parameter U
.Mono<U> getResult(PollingContext<T> pollingContext, TypeReference<U> resultType)
pollingContext
- the PollingContext
for the current polling operationresultType
- the TypeReference
of the final result object to deserialize into, or BinaryData if
raw response body should be kept.default Mono<T> cancel(PollingContext<T> pollingContext, PollResponse<T> initialResponse)
pollingContext
- the PollingContext
for the current polling operation, or null if the polling has
started in a SyncPoller
initialResponse
- the response from the initial operationCopyright © 2021 Microsoft Corporation. All rights reserved.