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

Implement waiters #3595

Merged
merged 12 commits into from Apr 25, 2024
Merged

Implement waiters #3595

merged 12 commits into from Apr 25, 2024

Conversation

jdisanti
Copy link
Collaborator

@jdisanti jdisanti commented Apr 19, 2024

This PR implements waiters according to the Smithy waiters spec.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 23, 2024
@smithy-lang smithy-lang deleted a comment from github-actions bot Apr 23, 2024
/// Wraps `v` in tracking associated with this builder
fn tracked<T>(&self, v: Option<T>) -> Option<Tracked<T>> {
v.map(|v| Tracked::new(self.builder_name, v))
}
}

// TODO(waiters): Decide if this is the right approach for extracting sleep_impl/time_source
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only big outstanding question on this PR. How exactly do we want to access components outside of the orchestrator prior to validation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the alternative? What are your concerns with this approach?

Copy link
Collaborator Author

@jdisanti jdisanti Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of a couple of alternatives:

  1. Add getter functions to RuntimeComponentsBuilder, or
  2. Create a OptionalRuntimeComponents struct that is analog to RuntimeComponents, but where creation doesn't do validation, and all the components in it are wrapped in Option. The RuntimeComponentsBuilder would have a build_optional function to create this.

The current approach is limited to time/sleep. In the future, some other non-time related component may be needed outside of the orchestrator. Given that, I think these alternatives would be better, but then it's just a matter of picking between them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think what you have is a one way door so I'm not too concerned.

@jdisanti jdisanti marked this pull request as ready for review April 23, 2024 22:45
@jdisanti jdisanti requested review from a team as code owners April 23, 2024 22:45
Copy link
Contributor

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great! Few questions and some discussion.

/// time being exceeded, or some other failure occurring.
#[derive(Debug)]
#[non_exhaustive]
pub enum WaiterError<O, E> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

/// Wraps `v` in tracking associated with this builder
fn tracked<T>(&self, v: Option<T>) -> Option<Tracked<T>> {
v.map(|v| Tracked::new(self.builder_name, v))
}
}

// TODO(waiters): Decide if this is the right approach for extracting sleep_impl/time_source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the alternative? What are your concerns with this approach?

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still going through the PR, but looks great so far. One clarifying question. .customize and .wait_XXX on a fluent builder cannot be used together, i.e. the following is not supported?

client
    .operation()
    .customize()
    .config_override(...)
    .wait_until_XXX
    ...

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! In codegen diff, I see the doc on a waiter's fluent builder look like

impl ImageExistsFluentBuilder {
    /// Creates a new `DescribeImages`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
        }
    }

It says /// Creates a new DescribeImages but not /// Creates a new ImageExistsFluentBuilder or /// Creates a new ImageExists. Is that expected?

@jdisanti
Copy link
Collaborator Author

Still going through the PR, but looks great so far. One clarifying question. .customize and .wait_XXX on a fluent builder cannot be used together, i.e. the following is not supported?

I opted to not support this yet without better understanding the use-case for it. It won't be hard to add if a good reason comes up.

@jdisanti
Copy link
Collaborator Author

It says /// Creates a new DescribeImages but not /// Creates a new ImageExistsFluentBuilder or /// Creates a new ImageExists. Is that expected?

No, this is a bug. Fixed in 8a3d012

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@jdisanti jdisanti added this pull request to the merge queue Apr 25, 2024
Merged via the queue into main with commit cfb97ed Apr 25, 2024
44 checks passed
@jdisanti jdisanti deleted the jdisanti-waiters branch April 25, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants