Skip to content

Commit 2b37a27

Browse files
committed
added inner in Client
1 parent c4888d6 commit 2b37a27

File tree

96 files changed

+523
-659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+523
-659
lines changed

benches/s3/common_benches.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ use minio_common::utils::{
2424
get_bytes_from_response, get_response_from_bytes, rand_bucket_name, rand_object_name,
2525
};
2626
use std::env;
27-
use std::sync::Arc;
27+
2828
use tokio::runtime::Runtime;
2929

3030
pub(crate) struct Ctx2 {
31-
pub client: Arc<Client>,
31+
pub client: Client,
3232
pub bucket: String,
3333
pub object: String,
3434
_cleanup: CleanupGuard,

common/src/cleanup_guard.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515

1616
use async_std::future::timeout;
1717
use minio::s3::Client;
18-
use std::sync::Arc;
18+
1919
use std::thread;
2020

2121
/// Cleanup guard that removes the bucket when it is dropped
2222
pub struct CleanupGuard {
23-
client: Arc<Client>,
23+
client: Client,
2424
bucket_name: String,
2525
}
2626

2727
impl CleanupGuard {
2828
#[allow(dead_code)]
29-
pub fn new(client: &Arc<Client>, bucket_name: &str) -> Self {
29+
pub fn new(client: &Client, bucket_name: &str) -> Self {
3030
Self {
31-
client: Arc::clone(client),
31+
client: client.clone(),
3232
bucket_name: bucket_name.to_string(),
3333
}
3434
}

common/src/test_context.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ use minio::s3::creds::StaticProvider;
2020
use minio::s3::http::BaseUrl;
2121
use minio::s3::types::S3Api;
2222
use std::path::{Path, PathBuf};
23-
use std::sync::Arc;
2423

2524
#[derive(Clone)]
2625
pub struct TestContext {
27-
pub client: Arc<Client>,
26+
pub client: Client,
2827
pub base_url: BaseUrl,
2928
pub access_key: String,
3029
pub secret_key: String,
@@ -58,15 +57,13 @@ impl TestContext {
5857
}
5958

6059
let static_provider = StaticProvider::new(&access_key, &secret_key, None);
61-
let client = Arc::new(
62-
Client::new(
63-
base_url.clone(),
64-
Some(Box::new(static_provider)),
65-
ssl_cert_file,
66-
Some(ignore_cert_check),
67-
)
68-
.unwrap(),
69-
);
60+
let client = Client::new(
61+
base_url.clone(),
62+
Some(Box::new(static_provider)),
63+
ssl_cert_file,
64+
Some(ignore_cert_check),
65+
)
66+
.unwrap();
7067

7168
Self {
7269
client,
@@ -117,15 +114,13 @@ impl TestContext {
117114
base_url.region = region;
118115

119116
let static_provider = StaticProvider::new(&access_key, &secret_key, None);
120-
let client = Arc::new(
121-
Client::new(
122-
base_url.clone(),
123-
Some(Box::new(static_provider)),
124-
Some(&*ssl_cert_file),
125-
Some(ignore_cert_check),
126-
)
127-
.unwrap(),
128-
);
117+
let client = Client::new(
118+
base_url.clone(),
119+
Some(Box::new(static_provider)),
120+
Some(&*ssl_cert_file),
121+
Some(ignore_cert_check),
122+
)
123+
.unwrap();
129124

130125
Self {
131126
client,

examples/bucket_encryption.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ use crate::common::{create_bucket_if_not_exists, create_client_on_play};
1919
use minio::s3::Client;
2020
use minio::s3::response::{GetBucketEncryptionResponse, SetBucketEncryptionResponse};
2121
use minio::s3::types::{S3Api, SseConfig};
22-
use std::sync::Arc;
2322

2423
#[tokio::main]
2524
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2625
env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher
27-
let client: Arc<Client> = create_client_on_play()?;
26+
let client: Client = create_client_on_play()?;
2827

2928
let bucket_name: &str = "encryption-rust-bucket";
3029
create_bucket_if_not_exists(bucket_name, &client).await?;

examples/bucket_lifecycle.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ use minio::s3::response::{
2121
DeleteBucketLifecycleResponse, GetBucketLifecycleResponse, SetBucketLifecycleResponse,
2222
};
2323
use minio::s3::types::{Filter, LifecycleConfig, LifecycleRule, S3Api};
24-
use std::sync::Arc;
2524

2625
#[tokio::main]
2726
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2827
env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher
29-
let client: Arc<Client> = create_client_on_play()?;
28+
let client: Client = create_client_on_play()?;
3029

3130
let bucket_name: &str = "lifecycle-rust-bucket";
3231
create_bucket_if_not_exists(bucket_name, &client).await?;

examples/bucket_versioning.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ use minio::s3::Client;
2020
use minio::s3::builders::VersioningStatus;
2121
use minio::s3::response::{GetBucketVersioningResponse, SetBucketVersioningResponse};
2222
use minio::s3::types::S3Api;
23-
use std::sync::Arc;
2423

2524
#[tokio::main]
2625
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2726
env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher
28-
let client: Arc<Client> = create_client_on_play()?;
27+
let client: Client = create_client_on_play()?;
2928

3029
let bucket_name: &str = "versioning-rust-bucket";
3130
create_bucket_if_not_exists(bucket_name, &client).await?;

examples/common.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ use minio::s3::http::BaseUrl;
33
use minio::s3::response::BucketExistsResponse;
44
use minio::s3::types::S3Api;
55
use minio::s3::{Client, ClientBuilder};
6-
use std::sync::Arc;
76

87
#[allow(dead_code)]
9-
pub fn create_client_on_play() -> Result<Arc<Client>, Box<dyn std::error::Error + Send + Sync>> {
8+
pub fn create_client_on_play() -> Result<Client, Box<dyn std::error::Error + Send + Sync>> {
109
let base_url = "https://play.min.io".parse::<BaseUrl>()?;
1110
log::info!("Trying to connect to MinIO at: `{:?}`", base_url);
1211

@@ -16,17 +15,15 @@ pub fn create_client_on_play() -> Result<Arc<Client>, Box<dyn std::error::Error
1615
None,
1716
);
1817

19-
let client = Arc::new(
20-
ClientBuilder::new(base_url.clone())
21-
.provider(Some(Box::new(static_provider)))
22-
.build()?,
23-
);
18+
let client = ClientBuilder::new(base_url.clone())
19+
.provider(Some(Box::new(static_provider)))
20+
.build()?;
2421
Ok(client)
2522
}
2623

2724
pub async fn create_bucket_if_not_exists(
2825
bucket_name: &str,
29-
client: &Arc<Client>,
26+
client: &Client,
3027
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
3128
// Check 'bucket_name' bucket exist or not.
3229
let resp: BucketExistsResponse = client.bucket_exists(bucket_name).send().await?;

examples/file_downloader.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ use minio::s3::Client;
2020
use minio::s3::builders::ObjectContent;
2121
use minio::s3::types::S3Api;
2222
use std::path::Path;
23-
use std::sync::Arc;
2423

2524
#[tokio::main]
2625
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2726
env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher
28-
let client: Arc<Client> = create_client_on_play()?;
27+
let client: Client = create_client_on_play()?;
2928

3029
let bucket_name: &str = "file-download-rust-bucket";
3130
let object_name: &str = "cat.png";

examples/file_uploader.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ use crate::common::{create_bucket_if_not_exists, create_client_on_play};
1818
use minio::s3::Client;
1919
use minio::s3::builders::ObjectContent;
2020
use std::path::Path;
21-
use std::sync::Arc;
2221

2322
#[tokio::main]
2423
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2524
env_logger::init(); // Note: set environment variable RUST_LOG="INFO" to log info and higher
26-
let client: Arc<Client> = create_client_on_play()?;
25+
let client: Client = create_client_on_play()?;
2726

2827
let bucket_name: &str = "file-upload-rust-bucket";
2928
create_bucket_if_not_exists(bucket_name, &client).await?;

examples/object_prompt.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use minio::s3::http::BaseUrl;
2323
use minio::s3::response::ObjectPromptResponse;
2424
use minio::s3::types::S3Api;
2525
use std::path::Path;
26-
use std::sync::Arc;
2726

2827
#[tokio::main]
2928
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
@@ -35,12 +34,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
3534

3635
let static_provider = StaticProvider::new("admin", "admin", None);
3736

38-
let client = Arc::new(
39-
ClientBuilder::new(base_url.clone())
40-
.provider(Some(Box::new(static_provider)))
41-
.ignore_cert_check(Some(true))
42-
.build()?,
43-
);
37+
let client = ClientBuilder::new(base_url.clone())
38+
.provider(Some(Box::new(static_provider)))
39+
.ignore_cert_check(Some(true))
40+
.build()?;
4441

4542
let bucket_name: &str = "object-prompt-rust-bucket";
4643
create_bucket_if_not_exists(bucket_name, &client).await?;

examples/put_object.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use minio::s3::response::BucketExistsResponse;
1919
use minio::s3::types::S3Api;
2020
use minio::s3::{Client, builders::ObjectContent, client::ClientBuilder, creds::StaticProvider};
2121
use std::path::PathBuf;
22-
use std::sync::Arc;
2322

2423
/// Upload a file to the given bucket and object path on the MinIO Play server.
2524
#[derive(Parser)]
@@ -42,11 +41,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
4241
None,
4342
);
4443

45-
let client: Arc<Client> = Arc::new(
46-
ClientBuilder::new("https://play.min.io".parse()?)
47-
.provider(Some(Box::new(static_provider)))
48-
.build()?,
49-
);
44+
let client: Client = ClientBuilder::new("https://play.min.io".parse()?)
45+
.provider(Some(Box::new(static_provider)))
46+
.build()?;
5047

5148
let resp: BucketExistsResponse = client.bucket_exists(&args.bucket).send().await.unwrap();
5249

src/s3/builders/append_object.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::sync::Arc;
3030
// region: append-object
3131
#[derive(Debug, Clone, Default)]
3232
pub struct AppendObject {
33-
client: Arc<Client>,
33+
client: Client,
3434

3535
extra_headers: Option<Multimap>,
3636
extra_query_params: Option<Multimap>,
@@ -47,14 +47,14 @@ pub struct AppendObject {
4747

4848
impl AppendObject {
4949
pub fn new(
50-
client: &Arc<Client>,
50+
client: &Client,
5151
bucket: String,
5252
object: String,
5353
data: SegmentedBytes,
5454
offset_bytes: u64,
5555
) -> Self {
5656
Self {
57-
client: Arc::clone(client),
57+
client: client.clone(),
5858
bucket,
5959
object,
6060
offset_bytes,
@@ -111,7 +111,7 @@ impl ToS3Request for AppendObject {
111111
///
112112
/// It is a higher level API and handles multipart appends transparently.
113113
pub struct AppendObjectContent {
114-
client: Arc<Client>,
114+
client: Client,
115115

116116
extra_headers: Option<Multimap>,
117117
extra_query_params: Option<Multimap>,
@@ -134,13 +134,13 @@ pub struct AppendObjectContent {
134134

135135
impl AppendObjectContent {
136136
pub fn new(
137-
client: &Arc<Client>,
137+
client: &Client,
138138
bucket: String,
139139
object: String,
140140
content: impl Into<ObjectContent>,
141141
) -> Self {
142142
Self {
143-
client: Arc::clone(client),
143+
client: client.clone(),
144144
bucket,
145145
object,
146146
input_content: content.into(),

src/s3/builders/bucket_common.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
// limitations under the License.
1515

1616
use std::marker::PhantomData;
17-
use std::sync::Arc;
1817

1918
use crate::s3::client::Client;
2019
use crate::s3::multimap::Multimap;
2120

22-
#[derive(Clone, Debug, Default)]
21+
#[derive(Clone, Default)]
2322
pub struct BucketCommon<A> {
24-
pub(crate) client: Arc<Client>,
23+
pub(crate) client: Client,
2524

2625
pub(crate) extra_headers: Option<Multimap>,
2726
pub(crate) extra_query_params: Option<Multimap>,
@@ -32,9 +31,9 @@ pub struct BucketCommon<A> {
3231
}
3332

3433
impl<A: Default> BucketCommon<A> {
35-
pub fn new(client: &Arc<Client>, bucket: String) -> BucketCommon<A> {
34+
pub fn new(client: Client, bucket: String) -> BucketCommon<A> {
3635
BucketCommon {
37-
client: Arc::clone(client),
36+
client,
3837
bucket,
3938
..Default::default()
4039
}

0 commit comments

Comments
 (0)