Documentation
¶
Index ¶
- Constants
- type DeadlineAwareRetryStrategy
- type DefaultEligibilityStrategy
- type EligibilityStrategy
- type ExponentialBackoffRetryStrategy
- type ExponentialBackoffRetryStrategyProps
- type FixedCountRetryStrategy
- type FixedCountRetryStrategyProps
- type FixedTimeoutRetryStrategy
- type FixedTimeoutRetryStrategyProps
- type LegacyTopicSubscriptionRetryStrategy
- type LegacyTopicSubscriptionRetryStrategyProps
- type OverrideDeadlineRetryStrategy
- type Strategy
- func NewExponentialBackoffRetryStrategy(props ExponentialBackoffRetryStrategyProps) Strategy
- func NewFixedCountRetryStrategy(props FixedCountRetryStrategyProps) Strategy
- func NewFixedTimeoutRetryStrategy(props FixedTimeoutRetryStrategyProps) Strategy
- func NewLegacyTopicSubscriptionRetryStrategy(props LegacyTopicSubscriptionRetryStrategyProps) Strategy
- func NewNeverRetryStrategy() Strategy
- func NewTimeoutAwareFixedCountRetryStrategy(props TimeoutAwareFixedCountRetryStrategyProps) Strategy
- type StrategyProps
- type TimeoutAwareEligibilityStrategy
- type TimeoutAwareFixedCountRetryStrategy
- type TimeoutAwareFixedCountRetryStrategyProps
Constants ¶
const ( DefaultInitialDelayMs = 0.5 DefaultGrowthFactor = 2 DefaultMaxBackoffMs = 8 )
const ( // DefaultRetryTimeoutMillis is the number of milliseconds the client is willing to wait for // a response on a retry attempt. Defaults to 1 second. DefaultRetryTimeoutMillis = 1000 // DefaultRetryDelayIntervalMillis is the number of milliseconds to wait between retry attempts. // Defaults to 100ms +/- jitter. DefaultRetryDelayIntervalMillis = 100 )
const ( // DefaultRetryTimeoutDuration is the duration the client is willing to wait for // a response on a retry attempt. Defaults to 500 milliseconds. DefaultRetryTimeoutDuration = 500 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeadlineAwareRetryStrategy ¶ added in v1.36.0
type DefaultEligibilityStrategy ¶
type DefaultEligibilityStrategy struct{}
DefaultEligibilityStrategy is the default strategy for determining if a request is eligible for retry.
func (DefaultEligibilityStrategy) IsEligibleForRetry ¶
func (s DefaultEligibilityStrategy) IsEligibleForRetry(props StrategyProps) bool
type EligibilityStrategy ¶
type EligibilityStrategy interface {
// IsEligibleForRetry Determines whether a grpc call is able to be retried. The determination is based on the result
// of the last invocation of the call and whether the call is idempotent.
IsEligibleForRetry(props StrategyProps) bool
}
type ExponentialBackoffRetryStrategyProps ¶
type ExponentialBackoffRetryStrategyProps struct {
LoggerFactory logger.MomentoLoggerFactory
EligibilityStrategy EligibilityStrategy
InitialDelayMillis float64
MaxBackoffMillis int
GrowthFactor int
}
type FixedCountRetryStrategy ¶
type FixedCountRetryStrategy interface {
Strategy
WithMaxAttempts(attempts int) Strategy
WithEligibilityStrategy(s EligibilityStrategy) Strategy
}
type FixedCountRetryStrategyProps ¶
type FixedCountRetryStrategyProps struct {
LoggerFactory logger.MomentoLoggerFactory
MaxAttempts int
EligibilityStrategy EligibilityStrategy
}
type FixedTimeoutRetryStrategy ¶ added in v1.36.0
type FixedTimeoutRetryStrategy interface {
DeadlineAwareRetryStrategy
WithRetryTimeoutMillis(timeout int) Strategy
WithRetryDelayIntervalMillis(delay int) Strategy
WithEligibilityStrategy(s EligibilityStrategy) Strategy
}
FixedTimeoutRetryStrategy is a retry strategy that retries a request up until the client timeout is reached. After the initial request fails, the next retry will be scheduled for retryDelayIntervalMillis from the current time, and the retried request will timeout after retryTimeoutMillis if there is no response.
type FixedTimeoutRetryStrategyProps ¶ added in v1.36.0
type FixedTimeoutRetryStrategyProps struct {
EligibilityStrategy EligibilityStrategy
LoggerFactory logger.MomentoLoggerFactory
RetryTimeoutMillis int
RetryDelayIntervalMillis int
}
type LegacyTopicSubscriptionRetryStrategy ¶ added in v1.35.0
type LegacyTopicSubscriptionRetryStrategyProps ¶ added in v1.35.0
type LegacyTopicSubscriptionRetryStrategyProps struct {
LoggerFactory logger.MomentoLoggerFactory
RetryMs *int
}
type OverrideDeadlineRetryStrategy ¶ added in v1.39.0
type Strategy ¶
type Strategy interface {
// DetermineWhenToRetry Determines whether a grpc call can be retried and how long to wait before that retry.
//
// StrategyProps - Information about the grpc call, its last invocation, and how many times the call
// has been made.
//
// Returns The time in milliseconds before the next retry should occur or nil if no retry should be attempted.
DetermineWhenToRetry(props StrategyProps) *int
}
func NewExponentialBackoffRetryStrategy ¶
func NewExponentialBackoffRetryStrategy(props ExponentialBackoffRetryStrategyProps) Strategy
func NewFixedCountRetryStrategy ¶
func NewFixedCountRetryStrategy(props FixedCountRetryStrategyProps) Strategy
func NewFixedTimeoutRetryStrategy ¶ added in v1.36.0
func NewFixedTimeoutRetryStrategy(props FixedTimeoutRetryStrategyProps) Strategy
func NewLegacyTopicSubscriptionRetryStrategy ¶ added in v1.35.0
func NewLegacyTopicSubscriptionRetryStrategy(props LegacyTopicSubscriptionRetryStrategyProps) Strategy
NewLegacyTopicSubscriptionRetryStrategy returns a strategy that always retries any request after a fixed delay. It is intended to maintain compatibility with the legacy behavior of Momento Topic subscriptions, which are now able to specify a retry strategy for determining when to reconnect to a subscription that has been interrupted. Switching to any of the other available retry strategies is recommended but not required and may require additional error handling after `Item()` or `Event()` calls as errors that previously resulted in a retry will now be returned to the caller. Deprecated: This strategy is deprecated and will be removed in a future release.
func NewNeverRetryStrategy ¶
func NewNeverRetryStrategy() Strategy
NewNeverRetryStrategy is a retry strategy that never retries any request
func NewTimeoutAwareFixedCountRetryStrategy ¶ added in v1.39.0
func NewTimeoutAwareFixedCountRetryStrategy(props TimeoutAwareFixedCountRetryStrategyProps) Strategy
type StrategyProps ¶
type TimeoutAwareEligibilityStrategy ¶ added in v1.39.0
type TimeoutAwareEligibilityStrategy struct{}
TimeoutAwareEligibilityStrategy is an eligibility strategy that treats DeadlineExceeded as retryable. It is used in conjunction with the TimeoutAwareFixedCountRetryStrategy.
Typically, a DeadlineExceeded would indicate that the overall client timeout has been reached and no further retries should be attempted. However, there are some cases where timeouts may occur due to the client being overloaded or experiencing transient network issues. In these cases, it may be beneficial to retry the request even if the overall timeout has been reached.
func (TimeoutAwareEligibilityStrategy) IsEligibleForRetry ¶ added in v1.39.0
func (s TimeoutAwareEligibilityStrategy) IsEligibleForRetry(props StrategyProps) bool
type TimeoutAwareFixedCountRetryStrategy ¶ added in v1.39.0
type TimeoutAwareFixedCountRetryStrategy interface {
Strategy
WithMaxAttempts(attempts int) Strategy
WithEligibilityStrategy(s EligibilityStrategy) Strategy
WithTimeoutDuration(duration time.Duration) Strategy
}
TimeoutAwareFixedCountRetryStrategy is a retry strategy that treats DeadlineExceeded as retryable. It is used in conjunction with the TimeoutAwareEligibilityStrategy.
Typically, a DeadlineExceeded would indicate that the overall client timeout has been reached and no further retries should be attempted. However, there are some cases where timeouts may occur due to the client being overloaded or experiencing transient network issues. In these cases, it may be beneficial to retry the request even if the overall timeout has been reached.
Note that this is different than using the FixedTimeoutRetryStrategy, which does not attempt a retry with a shorter timeout until after the first request fails due to a non-timeout error, and will retry only until the client's overall timeout is reached.
type TimeoutAwareFixedCountRetryStrategyProps ¶ added in v1.39.0
type TimeoutAwareFixedCountRetryStrategyProps struct {
LoggerFactory logger.MomentoLoggerFactory
MaxAttempts int
EligibilityStrategy EligibilityStrategy
TimeoutDuration time.Duration
}