Skip to content

Commit

Permalink
Update SNS client to retry on Throttling error
Browse files Browse the repository at this point in the history
  • Loading branch information
knovichikhin authored Sep 4, 2024
1 parent 2ab1257 commit cf4a8e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum SimpleNotificationClientError: Swift.Error {

public func isRetriable() -> Bool? {
switch self {
case .filterPolicyLimitExceeded, .kMSThrottling, .subscriptionLimitExceeded, .throttled, .topicLimitExceeded:
case .filterPolicyLimitExceeded, .kMSThrottling, .subscriptionLimitExceeded, .throttled, .throttling, .topicLimitExceeded:
return true
default:
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,24 @@ private let subscriptionLimitExceededIdentity = "SubscriptionLimitExceeded"
private let tagLimitExceededIdentity = "TagLimitExceeded"
private let tagPolicyIdentity = "TagPolicy"
private let throttledIdentity = "Throttled"
private let throttlingIdentity = "Throttling"
private let tooManyEntriesInBatchRequestIdentity = "TooManyEntriesInBatchRequest"
private let topicLimitExceededIdentity = "TopicLimitExceeded"
private let userErrorIdentity = "UserError"
private let validationIdentity = "ValidationException"
private let verificationIdentity = "VerificationException"
private let __accessDeniedIdentity = "AccessDenied"

public struct SimpleNotificationErrorPayload: Codable {
public let type: String
public let message: String

enum CodingKeys: String, CodingKey {
case type = "Code"
case message = "Message"
}
}

public enum SimpleNotificationError: Swift.Error, Decodable {
case authorizationError(AuthorizationErrorException)
case batchEntryIdsNotDistinct(BatchEntryIdsNotDistinctException)
Expand Down Expand Up @@ -99,6 +110,7 @@ public enum SimpleNotificationError: Swift.Error, Decodable {
case tagLimitExceeded(TagLimitExceededException)
case tagPolicy(TagPolicyException)
case throttled(ThrottledException)
case throttling(SimpleNotificationErrorPayload)
case tooManyEntriesInBatchRequest(TooManyEntriesInBatchRequestException)
case topicLimitExceeded(TopicLimitExceededException)
case userError(UserErrorException)
Expand Down Expand Up @@ -210,6 +222,9 @@ public enum SimpleNotificationError: Swift.Error, Decodable {
case throttledIdentity:
let errorPayload = try ThrottledException(from: decoder)
self = SimpleNotificationError.throttled(errorPayload)
case throttlingIdentity:
let errorPayload = try SimpleNotificationErrorPayload(from: decoder)
self = SimpleNotificationError.throttling(errorPayload)
case tooManyEntriesInBatchRequestIdentity:
let errorPayload = try TooManyEntriesInBatchRequestException(from: decoder)
self = SimpleNotificationError.tooManyEntriesInBatchRequest(errorPayload)
Expand Down

0 comments on commit cf4a8e8

Please sign in to comment.