From 72134a077ca60061487b33f331116c7a6e4ce932 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 30 Jun 2021 12:06:54 -0700 Subject: [PATCH] Refactored RDS code examples (#560) * Refactored RDS code examples to use common example pattern; re-ordered crates in Cargo.toml * Updated RDS helloworld code example to use ? instead of expect() --- aws/sdk/examples/rds/Cargo.toml | 1 - .../examples/rds/src/bin/rds-helloworld.rs | 24 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/aws/sdk/examples/rds/Cargo.toml b/aws/sdk/examples/rds/Cargo.toml index 9d7749475..0b42125c9 100644 --- a/aws/sdk/examples/rds/Cargo.toml +++ b/aws/sdk/examples/rds/Cargo.toml @@ -9,7 +9,6 @@ version = "0.1.0" [dependencies] rds = {package = "aws-sdk-rds", path = "../../build/aws-sdk/rds"} aws-types = { path = "../../build/aws-sdk/aws-types" } - tokio = {version = "1", features = ["full"]} structopt = { version = "0.3", default-features = false } tracing-subscriber = { version = "0.2.16", features = ["fmt"] } \ No newline at end of file diff --git a/aws/sdk/examples/rds/src/bin/rds-helloworld.rs b/aws/sdk/examples/rds/src/bin/rds-helloworld.rs index fde33ff07..3fdccbbf6 100644 --- a/aws/sdk/examples/rds/src/bin/rds-helloworld.rs +++ b/aws/sdk/examples/rds/src/bin/rds-helloworld.rs @@ -3,21 +3,17 @@ * SPDX-License-Identifier: Apache-2.0. */ -use rds::{Client, Config, Region}; - use aws_types::region::ProvideRegion; - +use rds::{Client, Config, Error, Region, PKG_VERSION}; use structopt::StructOpt; -use tracing_subscriber::fmt::format::FmtSpan; -use tracing_subscriber::fmt::SubscriberBuilder; #[derive(Debug, StructOpt)] struct Opt { - /// The region. Overrides environment variable AWS_DEFAULT_REGION. + /// The default AWS Region. #[structopt(short, long)] default_region: Option, - /// Whether to display additional runtime information + /// Whether to display additional information. #[structopt(short, long)] verbose: bool, } @@ -30,7 +26,9 @@ struct Opt { /// If the environment variable is not set, defaults to **us-west-2**. /// * `[-v]` - Whether to display additional information. #[tokio::main] -async fn main() -> Result<(), rds::Error> { +async fn main() -> Result<(), Error> { + tracing_subscriber::fmt::init(); + let Opt { default_region, verbose, @@ -43,13 +41,9 @@ async fn main() -> Result<(), rds::Error> { .unwrap_or_else(|| Region::new("us-west-2")); if verbose { - println!("RDS client version: {}\n", rds::PKG_VERSION); - println!("Region: {:?}", ®ion); - - SubscriberBuilder::default() - .with_env_filter("info") - .with_span_events(FmtSpan::CLOSE) - .init(); + println!("RDS version: {}", PKG_VERSION); + println!("Region: {:?}", ®ion); + println!(); } let conf = Config::builder().region(region).build(); -- GitLab