| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.EventHubs |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// An abstract representation of a policy to govern retrying of messaging operations. |
| | 11 | | /// </summary> |
| | 12 | | /// |
| | 13 | | /// <remarks> |
| | 14 | | /// It is recommended that developers without advanced needs not implement custom retry |
| | 15 | | /// policies but instead configure the default policy by specifying the desired set of |
| | 16 | | /// retry options when creating one of the Event Hubs clients. |
| | 17 | | /// </remarks> |
| | 18 | | /// |
| | 19 | | /// <seealso cref="EventHubsRetryOptions"/> |
| | 20 | | /// |
| | 21 | | public abstract class EventHubsRetryPolicy |
| | 22 | | { |
| | 23 | | /// <summary> |
| | 24 | | /// Calculates the amount of time to allow the current attempt for an operation to |
| | 25 | | /// complete before considering it to be timed out. |
| | 26 | | /// </summary> |
| | 27 | | /// |
| | 28 | | /// <param name="attemptCount">The number of total attempts that have been made, including the initial attempt b |
| | 29 | | /// |
| | 30 | | /// <returns>The amount of time to allow for an operation to complete.</returns> |
| | 31 | | /// |
| | 32 | | public abstract TimeSpan CalculateTryTimeout(int attemptCount); |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Calculates the amount of time to wait before another attempt should be made. |
| | 36 | | /// </summary> |
| | 37 | | /// |
| | 38 | | /// <param name="lastException">The last exception that was observed for the operation to be retried.</param> |
| | 39 | | /// <param name="attemptCount">The number of total attempts that have been made, including the initial attempt b |
| | 40 | | /// |
| | 41 | | /// <returns>The amount of time to delay before retrying the associated operation; if <c>null</c>, then the oper |
| | 42 | | /// |
| | 43 | | public abstract TimeSpan? CalculateRetryDelay(Exception lastException, |
| | 44 | | int attemptCount); |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Determines whether the specified <see cref="System.Object" /> is equal to this instance. |
| | 48 | | /// </summary> |
| | 49 | | /// |
| | 50 | | /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> |
| | 51 | | /// |
| | 52 | | /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c> |
| | 53 | | /// |
| | 54 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 55 | | public override bool Equals(object obj) => base.Equals(obj); |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// Returns a hash code for this instance. |
| | 59 | | /// </summary> |
| | 60 | | /// |
| | 61 | | /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha |
| | 62 | | /// |
| | 63 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 64 | | public override int GetHashCode() => base.GetHashCode(); |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Converts the instance to string representation. |
| | 68 | | /// </summary> |
| | 69 | | /// |
| | 70 | | /// <returns>A <see cref="System.String" /> that represents this instance.</returns> |
| | 71 | | /// |
| | 72 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 73 | | public override string ToString() => base.ToString(); |
| | 74 | | } |
| | 75 | | } |