Skip to content

Commit

Permalink
chore: bump oss sdk (#475)
Browse files Browse the repository at this point in the history
* update oss client and adapt to the new configuration

* add update log level return value

* add default value for oss options
  • Loading branch information
ZuLiangWang authored Dec 12, 2022
1 parent 3c75bf7 commit 1bba52e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions analytic_engine/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ fn open_storage(
aliyun_opts.key_secret,
aliyun_opts.endpoint,
aliyun_opts.bucket,
aliyun_opts.pool_max_idle_per_host,
aliyun_opts.timeout,
));
let oss_with_metrics = Arc::new(StoreWithMetrics::new(oss));
Arc::new(
Expand Down
18 changes: 17 additions & 1 deletion analytic_engine/src/storage_options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

use common_util::config::ReadableSize;
use std::time::Duration;

use common_util::config::{ReadableDuration, ReadableSize};
use serde::Deserialize;

#[derive(Debug, Clone, Deserialize)]
Expand Down Expand Up @@ -54,4 +56,18 @@ pub struct AliyunOptions {
pub endpoint: String,
pub bucket: String,
pub prefix: String,
#[serde(default = "AliyunOptions::default_pool_max_idle_per_host")]
pub pool_max_idle_per_host: usize,
#[serde(default = "AliyunOptions::default_timeout")]
pub timeout: ReadableDuration,
}

impl AliyunOptions {
fn default_pool_max_idle_per_host() -> usize {
1024
}

fn default_timeout() -> ReadableDuration {
ReadableDuration::from(Duration::from_secs(60))
}
}
2 changes: 1 addition & 1 deletion common_util/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl<'de> Deserialize<'de> for ReadableSize {
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Default)]
pub struct ReadableDuration(pub Duration);

impl Add for ReadableDuration {
Expand Down
2 changes: 1 addition & 1 deletion components/object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lazy_static = { workspace = true }
log = { workspace = true }
lru = { workspace = true }
lru-weighted-cache = { git = "https://github.com/jiacai2050/lru-weighted-cache.git", rev = "1cf61aaf88469387e610dc7154fa318843491428" }
oss-rust-sdk = { git = "https://github.com/jiacai2050/oss-rust-sdk.git", rev = "a6c54471d0b187667395d6cac931bd4e01a9f4e4" }
oss-rust-sdk = "0.6.1"
prost = { workspace = true }
proto = { workspace = true }
prometheus = { workspace = true }
Expand Down
14 changes: 11 additions & 3 deletions components/object_store/src/aliyun.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

use std::{collections::HashMap, fmt::Display, ops::Range};
use std::{collections::HashMap, fmt::Display, ops::Range, time::Duration};

use async_trait::async_trait;
use bytes::Bytes;
use futures::{
stream::{self, BoxStream},
StreamExt,
};
use oss_rust_sdk::{async_object::AsyncObjectAPI, errors::Error as AliyunError, prelude::OSS};
use oss_rust_sdk::{
async_object::AsyncObjectAPI, errors::Error as AliyunError, oss::Options, prelude::OSS,
};
use snafu::{ResultExt, Snafu};
use tokio::io::AsyncWrite;
use upstream::{
Expand Down Expand Up @@ -63,12 +65,18 @@ impl AliyunOSS {
key_secret: impl Into<String>,
endpoint: impl Into<String>,
bucket: impl Into<String>,
pool_max_idle_per_host: impl Into<usize>,
timeout: impl Into<Duration>,
) -> Self {
let oss = OSS::new(
let oss = OSS::new_with_opts(
key_id.into(),
key_secret.into(),
endpoint.into(),
bucket.into(),
Options {
pool_max_idle_per_host: Some(pool_max_idle_per_host.into()),
timeout: Some(timeout.into()),
},
);
Self { oss }
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl<Q: QueryExecutor + 'static> Service<Q> {
.set_level_by_str(log_level.as_str())
.map_err(|e| Error::HandleUpdateLogLevel { msg: e });
match result {
Ok(()) => Ok(reply::reply()),
Ok(()) => Ok(reply::json(&log_level)),
Err(e) => Err(reject::custom(e)),
}
},
Expand Down

0 comments on commit 1bba52e

Please sign in to comment.