Google API Client Library for .NET  1.10.0
Classes | Public Member Functions | Protected Member Functions | Properties | List of all members
Google.Apis.Http.BackOffHandler Class Reference

A thread-safe back-off handler which handles an abnormal HTTP response or an exception with Google.Apis.Util.IBackOff. More...

Inheritance diagram for Google.Apis.Http.BackOffHandler:
Google.Apis.Http.IHttpUnsuccessfulResponseHandler Google.Apis.Http.IHttpExceptionHandler

Classes

class  Initializer
 An initializer class to initialize a back-off handler. More...
 

Public Member Functions

 BackOffHandler (IBackOff backOff)
 Constructs a new back-off handler with the given back-off. More...
 
 BackOffHandler (Initializer initializer)
 Constructs a new back-off handler with the given initializer. More...
 
virtual async Task< bool > HandleResponseAsync (HandleUnsuccessfulResponseArgs args)
 Handles an abnormal response when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the abnormal response can be resolved, you must return true. More...
 
virtual async Task< bool > HandleExceptionAsync (HandleExceptionArgs args)
 Handles an exception thrown when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the exception can be resolved, you must return true. More...
 

Protected Member Functions

virtual async Task Wait (TimeSpan ts, CancellationToken cancellationToken)
 Waits the given time span. Overriding this method is recommended for mocking purposes. More...
 

Properties

IBackOff BackOff [get, set]
 Gets the back-off policy used by this back-off handler. More...
 
TimeSpan MaxTimeSpan [get, set]
 Gets the maximum time span to wait. If the back-off instance returns a greater time span, the handle method returns false. Default value is 16 seconds per a retry request. More...
 
Func< HttpResponseMessage, bool > HandleUnsuccessfulResponseFunc [get, set]
 Gets a delegate function which indicates whether this back-off handler should handle an abnormal HTTP response. The default is Initializer.DefaultHandleUnsuccessfulResponseFunc. More...
 
Func< Exception, bool > HandleExceptionFunc [get, set]
 Gets a delegate function which indicates whether this back-off handler should handle an exception. The default is Initializer.DefaultHandleExceptionFunc. More...
 

Detailed Description

A thread-safe back-off handler which handles an abnormal HTTP response or an exception with Google.Apis.Util.IBackOff.

Constructor & Destructor Documentation

Google.Apis.Http.BackOffHandler.BackOffHandler ( IBackOff  backOff)
inline

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

Parameters
backOffThe back-off policy.
Google.Apis.Http.BackOffHandler.BackOffHandler ( Initializer  initializer)
inline

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

Member Function Documentation

virtual async Task<bool> Google.Apis.Http.BackOffHandler.HandleExceptionAsync ( HandleExceptionArgs  args)
inlinevirtual

Handles an exception thrown when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the exception can be resolved, you must return true.

Parameters
argsHandle exception argument which properties such as the request, exception, current failed try.
Returns
Whether this handler has made a change that requires the request to be resent.

Implements Google.Apis.Http.IHttpExceptionHandler.

virtual async Task<bool> Google.Apis.Http.BackOffHandler.HandleResponseAsync ( HandleUnsuccessfulResponseArgs  args)
inlinevirtual

Handles an abnormal response when sending a HTTP request. A simple rule must be followed, if you modify the request object in a way that the abnormal response can be resolved, you must return true.

Parameters
argsHandle response argument which contains properties such as the request, response, current failed try.
Returns
Whether this handler has made a change that requires the request to be resent.

Implements Google.Apis.Http.IHttpUnsuccessfulResponseHandler.

virtual async Task Google.Apis.Http.BackOffHandler.Wait ( TimeSpan  ts,
CancellationToken  cancellationToken 
)
inlineprotectedvirtual

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

Parameters
tsTimeSpan to wait (and block the current thread).
cancellationTokenThe cancellation token in case the user wants to cancel the operation in the middle.

Property Documentation

IBackOff Google.Apis.Http.BackOffHandler.BackOff
getset

Gets the back-off policy used by this back-off handler.

Func<Exception, bool> Google.Apis.Http.BackOffHandler.HandleExceptionFunc
getset

Gets a delegate function which indicates whether this back-off handler should handle an exception. The default is Initializer.DefaultHandleExceptionFunc.

Func<HttpResponseMessage, bool> Google.Apis.Http.BackOffHandler.HandleUnsuccessfulResponseFunc
getset

Gets a delegate function which indicates whether this back-off handler should handle an abnormal HTTP response. The default is Initializer.DefaultHandleUnsuccessfulResponseFunc.

TimeSpan Google.Apis.Http.BackOffHandler.MaxTimeSpan
getset

Gets the maximum time span to wait. If the back-off instance returns a greater time span, the handle method returns false. Default value is 16 seconds per a retry request.


The documentation for this class was generated from the following file: