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

[Feature]: Support v2-to-v3 transformation of waiters #53

Closed
1 task
trivikr opened this issue Mar 7, 2022 · 4 comments · Fixed by #52
Closed
1 task

[Feature]: Support v2-to-v3 transformation of waiters #53

trivikr opened this issue Mar 7, 2022 · 4 comments · Fixed by #52
Labels
enhancement New feature or request

Comments

@trivikr
Copy link
Member

trivikr commented Mar 7, 2022

Self-service

  • I'd be willing to implement this feature

Input code

import AWS from "aws-sdk";

const Bucket = "BUCKET_NAME";
const client = new AWS.S3({ region: "REGION" });

await client.createBucket({ Bucket }).promise();
await client.waitFor("bucketExists", { Bucket }).promise();

Expected Output

import { S3, waitUntilBucketExists } from "@aws-sdk/client-s3";

const Bucket = "BUCKET_NAME";
const client = new S3({ region: "REGION" });

await client.createBucket({ Bucket });
await waitUntilBucketExists({ client, maxWaitTime: 60 }, { Bucket });

Additional context

Blog post: Waiters in modular AWS SDK for JavaScript

@trivikr trivikr added the enhancement New feature or request label Mar 7, 2022
@trivikr
Copy link
Member Author

trivikr commented Mar 7, 2022

A test added in PR #52

@trivikr
Copy link
Member Author

trivikr commented Dec 27, 2022

The waiter configuration in v2 has the following optional values:

  • delay: The number of seconds to wait between requests
  • maxAttempts: The maximum number of requests to send while waiting

If these values are not provided, the waiter waits indefinitely
Source code: https://github.com/aws/aws-sdk-js/blob/5ac0a5e169d3bf6c430be12f2d5e6fd528b682d4/lib/service.d.ts#L6-L16

The waiter configuration in v3 has the following equivalent values:

  • maxWaitTime: [required] The amount of time in seconds a user is willing to wait for a waiter to complete.
  • minDelay: The minimum amount of time to delay between retries in seconds
  • maxDelay: The maximum amount of time to delay between retries in seconds

Source code: https://github.com/aws/aws-sdk-js-v3/blob/6fe57fe8259ae25d1696ce7ff1765c5048715e23/packages/types/src/waiter.ts#L3-L38

The codemod will have to make following decisions:

  • What should be the default value of maxWaitTime in v3, if no options are defined in v2.
  • What should be the value of minDelay in v3, if delay is defined in v2.
  • What should be the value of maxWaitTime in v3, when:
    • Only maxAttempts is defined in v2.
    • When both delay and maxAttempts is defined in v2.

@trivikr
Copy link
Member Author

trivikr commented Dec 27, 2022

Decisions from internal discussions within AWS SDK for JavaScript team:

What should be the default value of maxWaitTime in v3, if no options are defined in v2.

180 seconds to be safe. We mention 60 seconds in Waiters in modular AWS SDK for JavaScript blog post.

What should be the value of minDelay in v3, if delay is defined in v2.

The value of delay should be same as minDelay

What should be the value of maxWaitTime in v3, when only maxAttempts is defined in v2.

The value in can be 2*10*maxAttempts to start with.

The waiter in v2 uses linear backoff. The multiplier 2 is added for service calls which happen during waiting time in v3.

The value of 10 is an approximate mean of minDelay provided in waiter models. In future, this value should be computed off minDelay numbers specific to service, and we should create a feature request for it.

What should be the value of maxWaitTime in v3, when both delay and maxAttempts is defined in v2.

The value can be 2*delay*maxAttempts complying to previous explanation.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant