Skip to content

Commit

Permalink
[smithy-rs] Delete aws_smithy_http::ResolveEndpoint and point usage…
Browse files Browse the repository at this point in the history
…s to service-specific trait (#3078)

## Motivation and Context
- Fixes smithy-lang/smithy-rs#3043

As a follow up to #3072 this removes the old endpoint resolver
interfaces in favor of creating a per-service resolver trait.

This trait defines a `into_shared_resolver()` method which converts the
local trait into a global resolver that can be used with the
orchestrator.

## Description
<!--- Describe your changes in detail -->

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## 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._
  • Loading branch information
rcoh authored and aws-sdk-rust-ci committed Nov 2, 2023
1 parent f75c1e1 commit 3c622ae
Show file tree
Hide file tree
Showing 731 changed files with 33,549 additions and 38,491 deletions.
70 changes: 26 additions & 44 deletions sdk/accessanalyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,63 +241,46 @@ impl Builder {
}
/// Sets the endpoint resolver to use when making requests.
///
/// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
///
///
/// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
/// rules for `aws_sdk_accessanalyzer`.
///
/// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
/// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
/// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
///
/// # Examples
/// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
/// ```no_run
/// use aws_smithy_http::endpoint;
/// use aws_sdk_accessanalyzer::config::endpoint::{Params as EndpointParams, DefaultResolver};
/// /// Endpoint resolver which adds a prefix to the generated endpoint
/// use aws_sdk_accessanalyzer::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
/// #[derive(Debug)]
/// struct PrefixResolver {
/// base_resolver: DefaultResolver,
/// prefix: String
/// }
/// impl endpoint::ResolveEndpoint<EndpointParams> for PrefixResolver {
/// fn resolve_endpoint(&self, params: &EndpointParams) -> endpoint::Result {
/// self.base_resolver
/// .resolve_endpoint(params)
/// .map(|ep|{
/// let url = ep.url().to_string();
/// ep.into_builder().url(format!("{}.{}", &self.prefix, url)).build()
/// })
/// }
/// struct StageResolver { stage: String }
/// impl ResolveEndpoint for StageResolver {
/// fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
/// let stage = &self.stage;
/// EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
/// }
/// }
/// let prefix_resolver = PrefixResolver {
/// base_resolver: DefaultResolver::new(),
/// prefix: "subdomain".to_string()
/// };
/// let config = aws_sdk_accessanalyzer::Config::builder().endpoint_resolver(prefix_resolver);
/// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
/// let config = aws_sdk_accessanalyzer::Config::builder().endpoint_resolver(resolver).build();
/// let client = aws_sdk_accessanalyzer::Client::from_conf(config);
/// ```
pub fn endpoint_resolver(
mut self,
endpoint_resolver: impl ::aws_smithy_http::endpoint::ResolveEndpoint<crate::config::endpoint::Params> + 'static,
) -> Self {
self.set_endpoint_resolver(::std::option::Option::Some(::aws_smithy_http::endpoint::SharedEndpointResolver::new(
endpoint_resolver,
)));
pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
self
}

/// Sets the endpoint resolver to use when making requests.
///
/// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
/// rules for `aws_sdk_accessanalyzer`.
pub fn set_endpoint_resolver(
&mut self,
endpoint_resolver: ::std::option::Option<::aws_smithy_http::endpoint::SharedEndpointResolver<crate::config::endpoint::Params>>,
endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
) -> &mut Self {
self.runtime_components.set_endpoint_resolver(endpoint_resolver.map(|r| {
::aws_smithy_runtime::client::orchestrator::endpoints::DefaultEndpointResolver::<crate::config::endpoint::Params>::new(
::aws_smithy_http::endpoint::SharedEndpointResolver::new(r),
)
}));
self.runtime_components.set_endpoint_resolver(endpoint_resolver);
self
}
/// Set the retry_config for the builder
Expand Down Expand Up @@ -967,11 +950,10 @@ impl ServiceRuntimePlugin {
::std::option::Option::Some(cfg.freeze())
};
let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
runtime_components.set_endpoint_resolver(Some(::aws_smithy_runtime::client::orchestrator::endpoints::DefaultEndpointResolver::<
crate::config::endpoint::Params,
>::new(::aws_smithy_http::endpoint::SharedEndpointResolver::new(
crate::config::endpoint::DefaultResolver::new(),
))));
runtime_components.set_endpoint_resolver(Some({
use crate::config::endpoint::ResolveEndpoint;
crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
}));
runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
Expand Down Expand Up @@ -1163,7 +1145,7 @@ pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_sm
/// Types needed to configure endpoint resolution.
pub mod endpoint;

/// Types needed to implement [`Interceptor`](crate::config::Interceptor).
/// Types needed to implement [`Intercept`](crate::config::Intercept).
pub mod interceptors;

/// Retry configuration.
Expand Down
Loading

0 comments on commit 3c622ae

Please sign in to comment.