Skip to content

Commit 3cc9397

Browse files
committed
Add EndpointOverrideRuntimePlugin to aws-runtime
Provides the runtime plugin that the generated code references to track endpoint override metrics.
1 parent fc81f4d commit 3cc9397

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
//! Endpoint override detection for business metrics tracking
7+
8+
use aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
9+
use aws_smithy_types::config_bag::{FrozenLayer, Layer};
10+
11+
use crate::sdk_feature::AwsSdkFeature;
12+
13+
/// Runtime plugin that tracks when a custom endpoint URL has been configured.
14+
#[derive(Debug, Default)]
15+
#[non_exhaustive]
16+
pub struct EndpointOverrideRuntimePlugin {
17+
config: Option<FrozenLayer>,
18+
}
19+
20+
impl EndpointOverrideRuntimePlugin {
21+
/// Creates a new `EndpointOverrideRuntimePlugin` with the endpoint override feature flag set
22+
pub fn new_with_feature_flag() -> Self {
23+
let mut layer = Layer::new("endpoint_override");
24+
layer.store_append(AwsSdkFeature::EndpointOverride);
25+
Self {
26+
config: Some(layer.freeze()),
27+
}
28+
}
29+
}
30+
31+
impl RuntimePlugin for EndpointOverrideRuntimePlugin {
32+
fn config(&self) -> Option<FrozenLayer> {
33+
self.config.clone()
34+
}
35+
}

aws/rust-runtime/aws-runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub mod content_encoding;
2626
/// Supporting code for recursion detection in the AWS SDK.
2727
pub mod recursion_detection;
2828

29+
/// Supporting code for endpoint override detection in the AWS SDK.
30+
pub mod endpoint_override;
31+
2932
/// Supporting code for user agent headers in the AWS SDK.
3033
pub mod user_agent;
3134

aws/rust-runtime/aws-runtime/src/sdk_feature.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub enum AwsSdkFeature {
2424
SsoLoginDevice,
2525
/// Calling an SSO-OIDC operation as part of the SSO login flow, when using the OAuth2.0 authorization code grant
2626
SsoLoginAuth,
27+
/// Indicates that a custom endpoint URL was configured
28+
EndpointOverride,
2729
}
2830

2931
impl Storable for AwsSdkFeature {

0 commit comments

Comments
 (0)