Skip to content

Commit

Permalink
refactor(retry): rename methods according to the ADR
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed Dec 19, 2023
1 parent 25f6f5a commit 1c291a2
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 180 deletions.
2 changes: 1 addition & 1 deletion PubNub/Data/PNConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ DEPRECATED_MSG_ATTRIBUTE("This property deprecated and will be removed with next
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearInterval];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearDelay];
/// ```
///
/// - Since: 5.3.0
Expand Down
112 changes: 55 additions & 57 deletions PubNub/Network/PNRequestRetryConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ NS_ASSUME_NONNULL_BEGIN

/// Request automatic retry configuration.
///
/// The **PubNub**'s client network layer uses retry configuration to calculate intervals between failed request
/// recovery attempts.
/// The **PubNub**'s client network layer uses retry configuration to calculate delays between failed request recovery
/// attempts.
///
/// - Since: 5.3.0
/// - Copyright: 2010-2023 PubNub, Inc.
Expand All @@ -20,152 +20,150 @@ NS_ASSUME_NONNULL_BEGIN

/// Create a request retry configuration with a linear retry policy.
///
/// Configurations with a linear retry policy will use equal intervals between retry attempts.
/// The default implementation uses a **2.0** seconds interval and **10** maximum retry attempts.
/// Configurations with a linear retry policy will use equal delays between retry attempts.
/// The default implementation uses a **2.0** seconds delay and **10** maximum retry attempts.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearInterval];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearDelay];
/// ```
///
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithLinearInterval;
+ (instancetype)configurationWithLinearDelay;

/// Create a request retry configuration with a linear retry policy.
///
/// Configurations with a linear retry policy will use equal intervals between retry attempts.
/// The default implementation uses a **2.0** seconds interval and **10** maximum retry attempts.
/// Configurations with a linear retry policy will use equal delays between retry attempts.
/// The default implementation uses a **2.0** seconds delay and **10** maximum retry attempts.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// // Disabling message publish and signal request automatic retry.
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearIntervalExcludingEndpoints:PNMessageSendEndpoint, 0];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearDelayExcludingEndpoints:PNMessageSendEndpoint, 0];
/// ```
///
/// - Parameter endpoints: A `0`-terminated list of endpoint groups for which automatic retry shouldn't be used.
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithLinearIntervalExcludingEndpoints:(PNEndpoint)endpoints, ...;
+ (instancetype)configurationWithLinearDelayExcludingEndpoints:(PNEndpoint)endpoints, ...;

/// Create a request retry configuration with a linear retry policy.
///
/// Configurations with a linear retry policy will use equal intervals between retry attempts.
/// Configurations with a linear retry policy will use equal delay between retry attempts.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// // Disabling message publish, signal and message storage access request automatic retry.
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearInterval:3.f
/// maximumRetryAttempts:3
/// excludedEndpoints:PNMessageSendEndpoint, PNMessageStorageEndpoint, 0];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithLinearDelay:3.f
/// maximumRetryAttempts:3
/// excludedEndpoints:PNMessageSendEndpoint, PNMessageStorageEndpoint, 0];
/// ```
///
/// - Parameters:
/// - interval: An interval between failed requests automatically retries attempts.
/// > Important: The minimum allowed interval is **2.0**.
/// - delay: Delay between failed requests automatically retries attempts.
/// > Important: The minimum allowed delay is **2.0**.
/// - maximumRetryAttempts: The number of failed requests that should be retried automatically before reporting an
/// error.
/// error.
/// > Important: The maximum allowed number of retries is **10**.
/// - endpoints: A `0`-terminated list of endpoint groups for which automatic retry shouldn't be used.
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithLinearInterval:(NSTimeInterval)interval
maximumRetryAttempts:(NSUInteger)maximumRetryAttempts
excludedEndpoints:(PNEndpoint)endpoints, ...;
+ (instancetype)configurationWithLinearDelay:(NSTimeInterval)delay
maximumRetryAttempts:(NSUInteger)maximumRetryAttempts
excludedEndpoints:(PNEndpoint)endpoints, ...;

/// Create a request retry configuration with a exponential retry policy.
///
/// Configurations with a exponential retry policy will use `minimumDelay` interval that will exponentially increase
/// with each failed request retry attempt.
/// The default implementation uses a **2.0** seconds minimum, **150** maximum intervals, and **6** maximum retry
/// attempts.
/// Configurations with an exponential retry policy will use `minimumDelay` that will exponentially increase with each
/// failed request retry attempt.
/// The default implementation uses a **2.0** seconds minimum, **150** maximum delays, and **6** maximum retry attempts.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialInterval];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialDelay];
/// ```
///
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithExponentialInterval;
+ (instancetype)configurationWithExponentialDelay;

/// Create a request retry configuration with a exponential retry policy.
///
/// Configurations with a exponential retry policy will use `minimumDelay` interval that will exponentially increase
/// with each failed request retry attempt.
/// The default implementation uses a **2.0** seconds minimum, **150** maximum intervals, and **6** maximum retry
/// attempts.
/// Configurations with an exponential retry policy will use `minimumDelay` that will exponentially increase with each
/// failed request retry attempt.
/// The default implementation uses a **2.0** seconds minimum, **150** maximum delays, and **6** maximum retry attempts.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// // Disabling message publish and signal request automatic retry.
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialIntervalExcludingEndpoints:PNMessageSendEndpoint, 0];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialDelayExcludingEndpoints:PNMessageSendEndpoint, 0];
/// ```
///
/// - Parameter endpoints: A `0`-terminated list of endpoint groups for which automatic retry shouldn't be used.
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithExponentialIntervalExcludingEndpoints:(PNEndpoint)endpoints, ...;
+ (instancetype)configurationWithExponentialDelayExcludingEndpoints:(PNEndpoint)endpoints, ...;

/// Create a request retry configuration with an exponential retry policy.
///
/// Configurations with an exponential retry policy will use a base interval that will exponentially increase with each
/// Configurations with an exponential retry policy will use `minimumDelay` that will exponentially increase with each
/// failed request retry attempt.
///
/// > Note: The PubNub client will schedule request retries after a calculated interval, but the actual retry may
/// not happen at the same moment (there is a small leeway).
/// > Note: The PubNub client will schedule request retries after a calculated delay, but the actual retry may not
/// happen at the same moment (there is a small leeway).
///
/// #### Example:
/// ```objc
/// PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
/// subscribeKey:@"demo"
/// userID:@"user"];
/// // Disabling message publish, signal and message storage access request automatic retry.
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialInterval:3.f
/// maximumInterval:120.f
/// maximumRetryAttempts:3
/// excludedEndpoints:PNMessageSendEndpoint, PNMessageStorageEndpoint, 0];
/// configuration.requestRetry = [PNRequestRetryConfiguration configurationWithExponentialDelay:3.f
/// maximumDelay:120.f
/// maximumRetryAttempts:3
/// excludedEndpoints:PNMessageSendEndpoint, PNMessageStorageEndpoint, 0];
/// ```
///
/// - Parameters:
/// - minimumInterval: Base interval, which will be used to calculate the next interval depending on the number of
/// retry attempts.
/// > Important: The minimum allowed interval is **2.0**.
/// - maximumInterval: Maximum allowed computed interval that should be used between retry attempts.
/// - minimumDelay: Base delay, which will be used to calculate the next delay depending on the number of retry
/// attempts.
/// > Important: The minimum allowed delay is **2.0**.
/// - maximumDelay: Maximum allowed computed delay that should be used between retry attempts.
/// - maximumRetryAttempts: The number of failed requests that should be retried automatically before reporting an
/// error.
/// > Important: The maximum allowed number of retries is **10**.
/// - endpoints: A `0`-terminated list of endpoint groups for which automatic retry shouldn't be used.
/// - Returns: Initialized automatic request retry configuration.
+ (instancetype)configurationWithExponentialInterval:(NSTimeInterval)minimumInterval
maximumInterval:(NSTimeInterval)maximumInterval
maximumRetryAttempts:(NSUInteger)maximumRetryAttempts
excludedEndpoints:(PNEndpoint)endpoints, ...;
+ (instancetype)configurationWithExponentialDelay:(NSTimeInterval)minimumDelay
maximumDelay:(NSTimeInterval)maximumDelay
maximumRetryAttempts:(NSUInteger)maximumRetryAttempts
excludedEndpoints:(PNEndpoint)endpoints, ...;

#pragma mark -

Expand Down
Loading

0 comments on commit 1c291a2

Please sign in to comment.