Unverified Commit 2d003567 authored by Thomas B's avatar Thomas B Committed by GitHub
Browse files

Make BehaviorVersion as future-proof as the documentation and RFC specify (#3513)



Fixes aws-sdk-rust#1111

This is *technically* a breaking change but since this was released
recently and it's documented that this API shouldn't be used, this can
probably be considered a bug, which is better fixed now than later.

---------

Co-authored-by: default avatarysaito1001 <awsaito@amazon.com>
parent f5f94a21
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16,3 +16,15 @@ message = "Clients now enforce that the Content-Length sent by the server matche
references = ["smithy-rs#3491", "aws-sdk-rust#1079"]
meta = { "breaking" = false, "bug" = true, "tada" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "Make `BehaviorVersion` be future-proof by disallowing it to be constructed via the `BehaviorVersion {}` syntax."
references = ["aws-sdk-rust#1111", "smithy-rs#3513"]
meta = { "breaking" = true, "tada" = false, "bug" = true }
author = "Ten0"

[[smithy-rs]]
message = "Make `BehaviorVersion` be future-proof by disallowing it to be constructed via the `BehaviorVersion {}` syntax."
references = ["aws-sdk-rust#1111", "smithy-rs#3513"]
meta = { "breaking" = true, "tada" = false, "bug" = true, "target" = "client" }
author = "Ten0"
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ In order to implement this feature, we need to create a `BehaviorVersion` struct
#[derive(Debug, Clone)]
pub struct BehaviorVersion {
    // currently there is only 1 MV so we don't actually need anything in here.
    _private: (),
}
```

+1 −1
Original line number Diff line number Diff line
[package]
name = "aws-smithy-runtime-api"
version = "1.2.0"
version = "1.3.0"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Zelda Hessler <zhessler@amazon.com>"]
description = "Smithy runtime types."
edition = "2021"
+20 −9
Original line number Diff line number Diff line
@@ -7,31 +7,42 @@

/// Behavior major-version of the client
///
/// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
/// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
/// all operations might be the ideal behavior but could break existing applications.
#[derive(Debug, Clone)]
pub struct BehaviorVersion {}
/// Over time, new best-practice behaviors are introduced. However, these behaviors might not be
/// backwards compatible. For example, a change which introduces new default timeouts or a new
/// retry-mode for all operations might be the ideal behavior but could break existing applications.
#[derive(Clone)]
pub struct BehaviorVersion {
    // currently there is only 1 MV so we don't actually need anything in here.
    _private: (),
}

impl BehaviorVersion {
    /// This method will always return the latest major version.
    ///
    /// This is the recommend choice for customers who aren't reliant on extremely specific behavior
    /// characteristics. For example, if you are writing a CLI app, the latest behavior major version
    /// is probably the best setting for you.
    /// characteristics. For example, if you are writing a CLI app, the latest behavior major
    /// version is probably the best setting for you.
    ///
    /// If, however, you're writing a service that is very latency sensitive, or that has written
    /// code to tune Rust SDK behaviors, consider pinning to a specific major version.
    ///
    /// The latest version is currently [`BehaviorVersion::v2023_11_09`]
    pub fn latest() -> Self {
        Self {}
        Self::v2023_11_09()
    }

    /// This method returns the behavior configuration for November 9th, 2023
    ///
    /// When a new behavior major version is released, this method will be deprecated.
    pub fn v2023_11_09() -> Self {
        Self {}
        Self { _private: () }
    }
}

impl std::fmt::Debug for BehaviorVersion {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("BehaviorVersion")
            .field("name", &"v2023_11_09")
            .finish()
    }
}