aws: use fixed BehaviorVersion

Quoting [`BehaviorVersion` documentation]:

> 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.

This commit uses `BehaviorVersion::v2023_11_09()`, which is the latest
major version at the moment. When a new major version is released, the method
will be deprecated, which will warn us of the new version and let us decide
when to upgrade, after any changes if required. This is safer that using
`latest()` which would silently use a different major version, possibly
breaking existing code.

[`BehaviorVersion` documentation]: https://docs.rs/aws-config/1.1.8/aws_config/struct.BehaviorVersion.html

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1531>
This commit is contained in:
François Laignel 2024-03-26 17:13:53 +01:00 committed by Sebastian Dröge
parent 6e126b9a3c
commit 85ce07d184
5 changed files with 19 additions and 10 deletions

View file

@ -18,7 +18,7 @@ mod s3hlssink;
mod s3sink;
mod s3src;
mod s3url;
mod s3utils;
pub mod s3utils;
mod transcribe_parse;
mod transcriber;

View file

@ -20,7 +20,10 @@ use std::sync::Mutex;
use std::time::Duration;
use tokio::runtime;
const DEFAULT_S3_REGION: &str = "us-west-2";
pub const DEFAULT_S3_REGION: &str = "us-west-2";
pub static AWS_BEHAVIOR_VERSION: Lazy<aws_config::BehaviorVersion> =
Lazy::new(aws_config::BehaviorVersion::v2023_11_09);
static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
runtime::Builder::new_multi_thread()
@ -111,12 +114,12 @@ pub fn wait_config(
.or_default_provider()
.or_else(Region::new(DEFAULT_S3_REGION));
let config_future = match credentials {
Some(cred) => aws_config::defaults(aws_config::BehaviorVersion::latest())
Some(cred) => aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
.timeout_config(timeout_config)
.region(region_provider)
.credentials_provider(cred)
.load(),
None => aws_config::defaults(aws_config::BehaviorVersion::latest())
None => aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
.timeout_config(timeout_config)
.region(region_provider)
.load(),

View file

@ -47,6 +47,9 @@ static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
.unwrap()
});
static AWS_BEHAVIOR_VERSION: Lazy<aws_config::BehaviorVersion> =
Lazy::new(aws_config::BehaviorVersion::v2023_11_09);
const DEFAULT_TRANSCRIBER_REGION: &str = "us-east-1";
// Deprecated in 0.11.0: due to evolutions of the transcriber element,
@ -545,7 +548,7 @@ impl Transcriber {
let config_loader = match (access_key, secret_access_key) {
(Some(key), Some(secret_key)) => {
gst::debug!(CAT, imp: self, "Using settings credentials");
aws_config::ConfigLoader::default().credentials_provider(
aws_config::defaults(AWS_BEHAVIOR_VERSION.clone()).credentials_provider(
aws_transcribe::config::Credentials::new(
key,
secret_key,
@ -557,7 +560,7 @@ impl Transcriber {
}
_ => {
gst::debug!(CAT, imp: self, "Attempting to get credentials from env...");
aws_config::defaults(aws_config::BehaviorVersion::latest())
aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
}
};

View file

@ -14,7 +14,7 @@
mod tests {
use gst::prelude::*;
const DEFAULT_S3_REGION: &str = "us-west-2";
use gstaws::s3utils::{AWS_BEHAVIOR_VERSION, DEFAULT_S3_REGION};
fn init() {
use std::sync::Once;
@ -40,7 +40,7 @@ mod tests {
)
.or_default_provider();
let config = aws_config::defaults(aws_config::BehaviorVersion::latest())
let config = aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
.region(region_provider)
.load()
.await;

View file

@ -33,6 +33,9 @@ use std::time::{Duration, SystemTime};
const DEFAULT_AWS_REGION: &str = "us-east-1";
const DEFAULT_PING_TIMEOUT: i32 = 30;
pub static AWS_BEHAVIOR_VERSION: Lazy<aws_config::BehaviorVersion> =
Lazy::new(aws_config::BehaviorVersion::v2023_11_09);
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"webrtc-aws-kvs-signaller",
@ -233,7 +236,7 @@ impl Signaller {
};
let client = Client::new(
&aws_config::defaults(aws_config::BehaviorVersion::latest())
&aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
.credentials_provider(credentials.clone())
.load()
.await,
@ -303,7 +306,7 @@ impl Signaller {
);
let signaling_config = aws_sdk_kinesisvideosignaling::config::Builder::from(
&aws_config::defaults(aws_config::BehaviorVersion::latest())
&aws_config::defaults(AWS_BEHAVIOR_VERSION.clone())
.credentials_provider(credentials.clone())
.load()
.await,