Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the AWS specific retry policy inheritable #1055

Closed
1 task done
aajtodd opened this issue Sep 27, 2023 · 1 comment · Fixed by #1122
Closed
1 task done

Make the AWS specific retry policy inheritable #1055

aajtodd opened this issue Sep 27, 2023 · 1 comment · Fixed by #1122
Assignees
Labels
feature-request A feature should be added or improved.

Comments

@aajtodd
Copy link
Collaborator

aajtodd commented Sep 27, 2023

Describe the feature

Customers often want/need to retry specific errors. They can do this now by re-using AwsDefaultRetryPolicy but because it's an object and not an open ended class to be extended from it limits how customers can implement custom policies (specifically they have to compose it into a new policy and delegate down to the default if needed).

e.g.

class CustomRetryPolicy : RetryPolicy<Any?> {
    override fun evaluate(result: Result<Any?>): RetryDirective {
        return when(result.exceptionOrNull()) {
            is IOException -> RetryDirective.RetryError(RetryErrorType.Transient)
            else -> AwsDefaultRetryPolicy.evaluate(result)
        }
    }
}

Is your Feature Request related to a problem?

See smithy-lang/smithy-kotlin#962 for one example.

Proposed Solution

refactor AwsDefaultRetryPolicy to look like the StandardRetryPolicy.

e.g.

public open class AwsRetryPolicy: StandardRetryPolicy() {
      companion object {
           val Default: AwsRetryPolicy = AwsRetryPolicy()
      }
      ...
}

Customer code becomes:

class CustomRetryPolicy: AwsRetryPolicy() {
    override fun evaluateSpecificExceptions(ex: Throwable): RetryDirective? = when(ex){
        is IOException -> RetryDirective.RetryError(RetryErrorType.Transient)
        else -> super.evaluateSpecificExceptions(ex)
    }
}

Describe alternative solutions or features you've considered

No response

Acknowledge

  • I may be able to implement this feature request

AWS Kotlin SDK version used

0.32.x+

Platform (JVM/JS/Native)

N/A

Operating System and version

N/A

@aajtodd aajtodd added the feature-request A feature should be added or improved. label Sep 27, 2023
@aajtodd aajtodd self-assigned this Nov 20, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant