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

Add support for TimeStreamWrite and TimeStreamQuery #2707

Merged
merged 5 commits into from
May 31, 2023
Merged

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented May 17, 2023

TODO:

  • docs
  • integration test (canary even?)
  • customize README for timestream

Motivation and Context

Description

This adds support for TSW and TSQ by adding endpoint discovery as a customization. This is made much simpler by the fact that endpoint discovery for these services has no parameters which means that there is no complexity from caching the returned endpoint.

Customers call .enable_endpoint_discovery() on the client to create a version of the client with endpoint discovery enabled. This returns a new client and a Reloader from which customers must spawn the reload task if they want endpoint discovery to rerun.

Testing

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

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

@rcoh rcoh requested a review from a team as a code owner May 17, 2023 18:03
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

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

This looks good, but seems like it is missing tests.

///
/// # Panics
/// This function panics if it is called from an asynchronous context
pub fn try_blocking_get(&self) -> Option<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't look like this is used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah deleted, an artifact from a previous impl

@@ -204,6 +204,7 @@ class ServiceConfigGenerator(private val customizations: List<ConfigCustomizatio
customizations.forEach {
it.section(ServiceConfig.ConfigStructAdditionalDocs)(writer)
}
Attribute(Attribute.derive(RuntimeType.Clone)).render(writer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be awesome if this could also derive Debug instead of the Debug impl that just outputs "Config"

@rcoh rcoh requested a review from a team as a code owner May 23, 2023 16:50
rcoh added a commit that referenced this pull request May 30, 2023
…hange warning is spurious) (#2728)

## Motivation and Context
- #2262 
- #2087 
- #2707 

This adds `TimeSource` in SDK and service configs so we can effectively
control time when executing requests with the SDK at the client level.

_note:_ the breaking change is in a trait implementation of a struct
we're going to delete, not a real breaking change

## Description
- Add `SharedTimeSource` and use it in SdkConfig / `aws-config` /
<service>::Config
- Wire up the signer and other uses of `SystemTime::now()` that I could
find
- track down broken tests

## Testing
- [x] various unit tests that all still pass

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
This adds support for TSW and TSQ by adding endpoint discovery as a customization. This is made much simpler by the fact that endpoint discovery for these services **has no parameters** which
means that there is no complexity from caching the returned endpoint.

Customers call `.enable_endpoint_discovery()` on the client to create a version of the client with endpoint discovery enabled. This returns a new client and a Reloader from which
customers must spawn the reload task if they want endpoint discovery to rerun.
@rcoh rcoh force-pushed the timestream-v1 branch 2 times, most recently from 760d379 to 47892e6 Compare May 31, 2023 12:48
@github-actions
Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

_ => {}
}
self.reload_increment(self.time.now()).await;
self.sleep.sleep(Duration::from_secs(60)).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

How was the 1min increment decided? A comment would be appreciated.

tracing::debug!(expiry = ?self.expiry, now = ?now, delta = ?self.expiry.duration_since(now), "checking expiry status of endpoint");
match self.expiry.duration_since(now) {
Err(_) => true,
Ok(t) => t < Duration::from_secs(120),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this value is meant to always be 2x the 1min duration, perhaps linking them together with consts would be a good idea. Of course, if we're never going to touch this stuff again then it's not important.

Comment on lines +132 to +133
// if we didn't successfully get an endpoint, bail out so the client knows
// configuration failed to work
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// if we didn't successfully get an endpoint, bail out so the client knows
// configuration failed to work
// if we failed to get an endpoint from the cache, bail out so that the client knows
// that configuration failed

.lock()
.unwrap()
.as_ref()
.map(|e| e.endpoint.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a map? Can't we just call clone directly?

Suggested change
.map(|e| e.endpoint.clone())
.clone()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is plucking out the endpoint in the map (not just cloning)

* 1. Adds the `endpoint_discovery` inlineable
* 2. Adds a `enable_endpoint_discovery` method on client that returns a wrapped client with endpoint discovery enabled
*/
class TimestreamDecorator : ClientCodegenDecorator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you actually use the crate docs decorator anywhere? I would have assumed there'd be something in here about how timestream support is experimental.

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 generated docs that add enable_endpoint_discovery—I figure our standard boilerplate is probably good for starters

@rcoh rcoh added this pull request to the merge queue May 31, 2023
Merged via the queue into main with commit 8c045d2 May 31, 2023
@rcoh rcoh deleted the timestream-v1 branch May 31, 2023 18:34
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.

3 participants