C# Class Google.Apis.Http.BackOffHandler

A thread-safe back-off handler which handles an abnormal HTTP response or an exception with Google.Apis.Util.IBackOff.
Inheritance: IHttpUnsuccessfulResponseHandler, IHttpExceptionHandler
Exibir arquivo Open project: Gainedge/BetterExplorer Class Usage Examples

Public Methods

Method Description
BackOffHandler ( IBackOff backOff ) : System

Constructs a new back-off handler with the given back-off.

BackOffHandler ( Initializer initializer ) : System

Constructs a new back-off handler with the given initializer.

HandleExceptionAsync ( Google.Apis.Http.HandleExceptionArgs args ) : Task
HandleResponseAsync ( Google.Apis.Http.HandleUnsuccessfulResponseArgs args ) : Task

Protected Methods

Method Description
Wait ( System.TimeSpan ts, CancellationToken cancellationToken ) : Task

Waits the given time span. Overriding this method is recommended for mocking purposes.

Private Methods

Method Description
HandleAsync ( bool supportsRetry, int currentFailedTry, CancellationToken cancellationToken ) : Task

Handles back-off. In case the request doesn't support retry or the back-off time span is greater than the maximum time span allowed for a request, the handler returns false. Otherwise the current thread will block for x milliseconds (x is defined by the BackOff instance), and this handler returns true.

Method Details

BackOffHandler() public method

Constructs a new back-off handler with the given back-off.
public BackOffHandler ( IBackOff backOff ) : System
backOff IBackOff The back-off policy.
return System

BackOffHandler() public method

Constructs a new back-off handler with the given initializer.
public BackOffHandler ( Initializer initializer ) : System
initializer Initializer
return System

HandleExceptionAsync() public method

public HandleExceptionAsync ( Google.Apis.Http.HandleExceptionArgs args ) : Task
args Google.Apis.Http.HandleExceptionArgs
return Task

HandleResponseAsync() public method

public HandleResponseAsync ( Google.Apis.Http.HandleUnsuccessfulResponseArgs args ) : Task
args Google.Apis.Http.HandleUnsuccessfulResponseArgs
return Task

Wait() protected method

Waits the given time span. Overriding this method is recommended for mocking purposes.
protected Wait ( System.TimeSpan ts, CancellationToken cancellationToken ) : Task
ts System.TimeSpan TimeSpan to wait (and block the current thread).
cancellationToken System.Threading.CancellationToken The cancellation token in case the user wants to cancel the operation in /// the middle.
return Task