-
Notifications
You must be signed in to change notification settings - Fork 190
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
Simplify default config and add default async sleep #3071
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just skimmed, need to come back for detailed review
pub struct ClientRateLimiterRuntimePlugin { | ||
rate_limiter: ClientRateLimiter, | ||
} | ||
|
||
impl ClientRateLimiterRuntimePlugin { | ||
/// Create a new [`ClientRateLimiterRuntimePlugin`]. | ||
pub fn new(seconds_since_unix_epoch: f64) -> Self { | ||
Self { | ||
rate_limiter: ClientRateLimiter::new(seconds_since_unix_epoch), | ||
} | ||
} | ||
} | ||
|
||
impl RuntimePlugin for ClientRateLimiterRuntimePlugin { | ||
fn config(&self) -> Option<FrozenLayer> { | ||
let mut cfg = Layer::new("client rate limiter"); | ||
cfg.store_put(self.rate_limiter.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this something a customer would want to use directly? Seems like it could be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an implementation detail for adaptive retry, so I don't believe so.
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
let _default: Option<SharedHttpClient> = None; | ||
#[cfg(feature = "connector-hyper-0-14-x")] | ||
let _default = crate::client::http::hyper_014::default_client(); | ||
|
||
_default.map(|default| { | ||
default_plugin("default_http_client_plugin", |components| { | ||
components.with_http_client(Some(default)) | ||
}) | ||
.into_shared() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let _default: Option<SharedHttpClient> = None; | |
#[cfg(feature = "connector-hyper-0-14-x")] | |
let _default = crate::client::http::hyper_014::default_client(); | |
_default.map(|default| { | |
default_plugin("default_http_client_plugin", |components| { | |
components.with_http_client(Some(default)) | |
}) | |
.into_shared() | |
}) | |
let default_client: Option<SharedHttpClient> = None; | |
#[cfg(feature = "connector-hyper-0-14-x")] | |
let default_client = crate::client::http::hyper_014::default_client(); | |
default_client.map(|client| { | |
default_plugin("default_http_client_plugin", |components| { | |
components.with_http_client(Some(client)) | |
}) | |
.into_shared() | |
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely needs the underscore prefix to avoid compilation warnings.
Some( | ||
default_plugin("default_time_source_plugin", |components| { | ||
components.with_time_source(Some(SystemTimeSource::new())) | ||
}) | ||
.into_shared(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonblocking—I wonder if we could figure out at compile time if SystemTimeSource
was going to work or not 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to look at the compilation target to determine that.
@@ -16,6 +17,8 @@ import software.amazon.smithy.rust.codegen.core.testutil.integrationTest | |||
|
|||
class SensitiveOutputDecoratorTest { | |||
private fun codegenScope(runtimeConfig: RuntimeConfig): Array<Pair<String, Any>> = arrayOf( | |||
"capture_test_logs" to CargoDependency.smithyRuntimeTestUtil(runtimeConfig).toType() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting to use this, which I did not when adding this test.
A new generated diff is ready to view.
A new doc preview is ready to view. |
While implementing identity caching, I noticed we don't have a default async sleep impl wired up for generic clients, which was causing caching to panic in many tests since it needs a sleep impl for timeouts. I likely need to figure out what to do other than panic if there's no sleep impl, but that's a problem for a different PR.
This PR adds a default sleep impl to generic clients, and also simplifies how default config works. Previously, the generated config
Builder::build
method set all the defaults with a series of "if not set, then set default" statements. In this PR, defaults are registered via default ordered runtime plugins.Additionally, I cleaned up the standard retry strategy:
TokenBucketPartition
didn't appear to be used at all, so I deleted it.StandardRetryStrategy
was taking retry config at construction, which means it isn't possible to config override the retry config unless the strategy is recreated. It now doesn't take any config at all during construction.Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.