Skip to content

Commit

Permalink
Change resolve_endpoint to use EndpointFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahad Zubair committed Oct 19, 2023
1 parent d07d1a7 commit a1366a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion examples/pokemon-service-client-usage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ pokemon-service-client = { path = "../pokemon-service-client/" }
# Required for getting the operation name from the `Metadata`.
aws-smithy-http = { path = "../../rust-runtime/aws-smithy-http/" }

# Required for building an `Endpoint` in `custom-header-using-interceptor` example.
# Required for `Storable` and `StoreReplace` in `response-header-interceptor` example.
aws-smithy-types = { path = "../../rust-runtime/aws-smithy-types/" }

# Required for `HyperClientBuilder` in `client-connector` example.
aws-smithy-runtime = { path = "../../rust-runtime/aws-smithy-runtime/", features=["test-util"] }



hyper = { version = "0.14.25", features = ["client", "full"] }
tokio = {version = "1.26.0", features=["full"]}
tracing = "0.1.37"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn create_client() -> PokemonClient {
// The generated client has a type `Config::Builder` that can be used to build a `Config`, which
// allows configuring endpoint-resolver, timeouts, retries etc.
let config = pokemon_service_client::Config::builder()
.endpoint_resolver(POKEMON_SERVICE_URL)
.endpoint_url(POKEMON_SERVICE_URL)
.interceptor(ttl_headers_interceptor)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
///
/// The example can be run using `cargo run --example endpoint-resolver`.
///
use aws_smithy_types::endpoint::Endpoint;
use pokemon_service_client::config::endpoint::{Params, ResolveEndpoint};
use pokemon_service_client::config::endpoint::{Endpoint, EndpointFuture, Params, ResolveEndpoint};
use pokemon_service_client::primitives::{DateTime, DateTimeFormat};
use pokemon_service_client::Client as PokemonClient;
use pokemon_service_client_usage::setup_tracing_subscriber;
Expand All @@ -22,6 +21,7 @@ use std::time::SystemTime;

// This struct, provided as an example, constructs the URL that should be set on each request during initialization.
// It also implements the `ResolveEndpoint` trait, enabling it to be assigned as the endpoint_resolver in the `Config`.
#[derive(Debug)]
struct RegionalEndpoint {
url_to_use: String,
}
Expand All @@ -33,8 +33,8 @@ impl RegionalEndpoint {
}
}

impl ResolveEndpoint<Params> for RegionalEndpoint {
fn resolve_endpoint(&self, _: &Params) -> aws_smithy_http::endpoint::Result {
impl ResolveEndpoint for RegionalEndpoint {
fn resolve_endpoint<'a>(&'a self, _params: &'a Params) -> EndpointFuture<'a> {
// Construct an endpoint using the Endpoint::Builder. Set the URL and,
// optionally, any headers to be sent with the request. For this example,
// we'll set the 'x-amz-date' header to the current date for all outgoing requests.
Expand All @@ -51,9 +51,8 @@ impl ResolveEndpoint<Params> for RegionalEndpoint {
.expect("Could not create a date in UTC format"),
)
.build();

tracing::info!(?endpoint, "Resolving endpoint");
Ok(endpoint)
EndpointFuture::ready(Ok(endpoint))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
///
/// The example can be run using `cargo run --example response-header-interceptor`.
///
//use aws_smithy_types::config_bag::{Storable, StoreReplace};
use aws_smithy_types::config_bag::{Storable, StoreReplace};
use pokemon_service_client::{
config::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use aws_smithy_types::config_bag::{Storable, StoreReplace};
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
Expand All @@ -13,6 +12,7 @@ use aws_smithy_types::config_bag::{Storable, StoreReplace};
/// The example can be run using `cargo run --example use-config-bag`.
///
//use aws_smithy_types::config_bag::{Storable, StoreReplace};
use aws_smithy_types::config_bag::{Storable, StoreReplace};
use pokemon_service_client_usage::{setup_tracing_subscriber, POKEMON_SERVICE_URL};
use std::time::Instant;

Expand Down

0 comments on commit a1366a2

Please sign in to comment.