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

Timestream's ReloadEndpoint is unclear #1124

Open
simbleau opened this issue Apr 9, 2024 · 5 comments
Open

Timestream's ReloadEndpoint is unclear #1124

simbleau opened this issue Apr 9, 2024 · 5 comments
Labels
documentation This is a problem with documentation p2 This is a standard priority issue

Comments

@simbleau
Copy link

simbleau commented Apr 9, 2024

Describe the issue

I've made good attempts to understand how Timestream's ReloadEndpoint works, which doesn't seem to documented well. It still doesn't make sense to me, unfortunately.

The docs.rs of ReloadEndpoint only says "Endpoint reloader."

Here's roughly our code:

    let config = aws_config::defaults(aws_config::BehaviorVersion::latest())
        .region(REGION)
        .load()
        .await;
    let (client, reload) = aws_sdk_timestreamwrite::Client::new(&config)
        .with_endpoint_discovery_enabled()
        .await
        .unwrap();

    // This task will terminate when the corresponding Client is dropped.
    tokio::task::spawn(reload.reload_task());

    ... work with the client here.

My questions are:

  • What function does the ReloadEndpoint have?
  • Why do we need to call .with_endpoint_discovery_enabled()? It will not work without this.
  • It seems to work without me spawning the reload task - What does that task really do then?

Links

/// Enable endpoint discovery for this client
///
/// This method MUST be called to construct a working client.
pub async fn with_endpoint_discovery_enabled(
self,
) -> ::std::result::Result<(Self, crate::endpoint_discovery::ReloadEndpoint), ::aws_smithy_runtime_api::box_error::BoxError> {

@simbleau simbleau added documentation This is a problem with documentation needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
@jdisanti
Copy link
Contributor

jdisanti commented Apr 9, 2024

What function does the ReloadEndpoint have?

ReloadEndpoint enables you to decide whether you want to do your own endpoint refreshing, or if you want to have the SDK do it for you. It has the reload_once function if you want to do it yourself. Otherwise, you'll want to spawn reload_task.

Why do we need to call .with_endpoint_discovery_enabled()? It will not work without this.

I can't remember exactly why we made this opt-in instead of opt-out, but the general idea is that endpoint discovery makes service calls on your behalf to figure out what the endpoint is. So this is a bit more explicit that it's doing that.

It seems to work without me spawning the reload task - What does that task really do then?

I think .with_endpoint_discovery_enabled() will make it do an initial load, and then it needs to be refreshed later. Although, perhaps, it might just work for a while without refreshing. I don't think there's any documented expiration time on there. The SDK refreshes it every 60 seconds if using reload_task.

@jdisanti
Copy link
Contributor

jdisanti commented Apr 9, 2024

Leaving this open to track improving documentation.

@jdisanti jdisanti added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
@rcoh
Copy link
Contributor

rcoh commented Apr 10, 2024

This can now be improved with the SRA I think. When the code was written, resolve endpoint was synchronous (hence the need for background refresh).

@simbleau
Copy link
Author

simbleau commented Apr 10, 2024

Thanks John, appreciate the quick reply.

ReloadEndpoint enables you to decide whether you want to do your own endpoint refreshing, or if you want to have the SDK do it for you. It has the reload_once function if you want to do it yourself. Otherwise, you'll want to spawn reload_task.

I'm still not understanding what endpoint refreshing is and why it's necessary. Is the endpoint just the correct place to talk to Timestream?

I found https://docs.aws.amazon.com/general/latest/gr/timestream.html - I assume it is related. However in this documentation, it seems like the endpoint is constant. What does reloading the endpoint accomplish?

@jdisanti
Copy link
Contributor

Endpoint discovery is a more general SDK feature. I'm not so familiar with Timestream, so I can't say one way or another if the endpoints change, but DynamoDB also uses endpoint discovery, and I think the endpoints can change there. Or at the very least, they're allowed to change, and thus, must be refreshed periodically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants