Skip to content

Commit

Permalink
Merge pull request #17 from qiniu/releases/v0.2.1
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
bachue authored Oct 26, 2022
2 parents f3ce289 + 33fb7e1 commit 9796bfa
Show file tree
Hide file tree
Showing 48 changed files with 1,934 additions and 838 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ jobs:
RUST_LOG: "debug"
RUST_BACKTRACE: "1"
SKIP_CLIPPY: "1"
CLEAN_BEFORE_EACH: "1"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log

## v0.2.1

- `qiniu_upload_manager::MultiPartsV1Uploader` 总是使用 4 MB 分片大小,无论 `qiniu_upload_manager::DataPartitionProvider` 返回多大的分片大小。
- `qiniu_upload_manager::SerialMultiPartsUploaderScheduler``qiniu_upload_manager::ConcurrentMultiPartsUploaderScheduler` 对空间所在区域上传对象失败后,会使用多活区域继续重试,直到其中有一个能成功为止。

## v0.2.0

- 大部分 Trait 现在都实现了 Clone,减少了泛型参数以方便被作为 Trait Object 使用
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ doc_test:
test:
set -e; \
for dir in $(SUBDIRS); do \
if [ -n "${CLEAN_BEFORE_EACH}" ]; then \
$(MAKE) clean; \
fi; \
$(MAKE) -C $$dir test; \
done
clean:
Expand Down
10 changes: 5 additions & 5 deletions api-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-api-generator"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand Down Expand Up @@ -29,8 +29,8 @@ walkdir = "2.3.2"

[dev-dependencies]
serde_json = "1.0.68"
qiniu-http = { version = "0.2.0", path = "../http" }
qiniu-http-client = { version = "0.2.0", path = "../http-client" }
qiniu-upload-token = { version = "0.2.0", path = "../upload-token" }
qiniu-utils = { version = "0.2.0", path = "../utils" }
qiniu-http = { version = "0.2.1", path = "../http" }
qiniu-http-client = { version = "0.2.1", path = "../http-client" }
qiniu-upload-token = { version = "0.2.1", path = "../upload-token" }
qiniu-utils = { version = "0.2.1", path = "../utils" }
indexmap = "1.7.0"
6 changes: 3 additions & 3 deletions apis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-apis"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand All @@ -22,8 +22,8 @@ indexmap = "1.7.0"
futures = { version = "0.3.5", optional = true }
async-std = { version = "1.9.0", optional = true }

qiniu-http-client = { version = "0.2.0", path = "../http-client", default-features = false }
qiniu-utils = { version = "0.2.0", path = "../utils" }
qiniu-http-client = { version = "0.2.1", path = "../http-client", default-features = false }
qiniu-utils = { version = "0.2.1", path = "../utils" }

[features]
default = ["ureq"]
Expand Down
6 changes: 3 additions & 3 deletions apis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@

```toml
[dependencies]
qiniu-apis = { version = "0.2.0", features = ["ureq"] }
qiniu-apis = { version = "0.2.1", features = ["ureq"] }
```

### 启用 Isahc 异步接口

```toml
[dependencies]
qiniu-apis = { version = "0.2.0", features = ["async", "isahc"] }
qiniu-apis = { version = "0.2.1", features = ["async", "isahc"] }
```

### 启用 Reqwest 异步接口

```toml
[dependencies]
qiniu-apis = { version = "0.2.0", features = ["async", "reqwest"] }
qiniu-apis = { version = "0.2.1", features = ["async", "reqwest"] }
```

### 其他功能
Expand Down
4 changes: 2 additions & 2 deletions credential/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-credential"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand All @@ -24,7 +24,7 @@ assert-impl = "0.1.3"
auto_impl = "1.0.0"
futures-lite = { version = "1.12.0", optional = true }

qiniu-utils = { version = "0.2.0", path = "../utils" }
qiniu-utils = { version = "0.2.1", path = "../utils" }

[dev-dependencies]
anyhow = "1.0.41"
Expand Down
4 changes: 2 additions & 2 deletions credential/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

```toml
[dependencies]
qiniu-credential = "0.2.0"
qiniu-credential = "0.2.1"
```

### 启用异步接口

```toml
[dependencies]
qiniu-credential = { version = "0.2.0", features = ["async"] }
qiniu-credential = { version = "0.2.1", features = ["async"] }
```

## 代码示例
Expand Down
4 changes: 2 additions & 2 deletions download-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-download-manager"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand All @@ -26,7 +26,7 @@ futures = { version = "0.3.5", optional = true }
async-std = { version = "1.9.0", optional = true }
smart-default = { version = "0.6.0", optional = true }

qiniu-apis = { version = "0.2.0", path = "../apis", default-features = false }
qiniu-apis = { version = "0.2.1", path = "../apis", default-features = false }

[dev-dependencies]
rand = "0.8.3"
Expand Down
6 changes: 3 additions & 3 deletions download-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

```toml
[dependencies]
qiniu-download-manager = { version = "0.2.0", features = ["ureq"] }
qiniu-download-manager = { version = "0.2.1", features = ["ureq"] }
```

### 启用 Isahc 异步接口

```toml
[dependencies]
qiniu-download-manager = { version = "0.2.0", features = ["async", "isahc"] }
qiniu-download-manager = { version = "0.2.1", features = ["async", "isahc"] }
```

### 启用 Reqwest 异步接口

```toml
[dependencies]
qiniu-download-manager = { version = "0.2.0", features = ["async", "reqwest"] }
qiniu-download-manager = { version = "0.2.1", features = ["async", "reqwest"] }
```

### 其他功能
Expand Down
4 changes: 2 additions & 2 deletions etag/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-etag"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand All @@ -19,7 +19,7 @@ digest = "0.9.0"
assert-impl = "0.1.3"
futures-lite = { version = "1.12.0", optional = true }

qiniu-utils = { version = "0.2.0", path = "../utils" }
qiniu-utils = { version = "0.2.1", path = "../utils" }

[dev-dependencies]
async-std = { version = "1.9.0", features = ["attributes"] }
Expand Down
4 changes: 2 additions & 2 deletions etag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

```toml
[dependencies]
qiniu-etag = "0.2.0"
qiniu-etag = "0.2.1"
```

### 启用异步接口

```toml
[dependencies]
qiniu-etag = { version = "0.2.0", features = ["async"] }
qiniu-etag = { version = "0.2.1", features = ["async"] }
```

## 代码示例
Expand Down
16 changes: 8 additions & 8 deletions http-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qiniu-http-client"
version = "0.2.0"
version = "0.2.1"
authors = ["Rong Zhou <[email protected]>", "Shanghai Qiniu Information Technologies Co., Ltd."]
edition = "2021"
rust-version = "1.60.0"
Expand Down Expand Up @@ -56,13 +56,13 @@ trust-dns-resolver = { version = "0.21.2", optional = true }
async-std-resolver = { version = "0.21.2", optional = true }
async-once-cell = { version = "0.3.0", optional = true }

qiniu-http = { version = "0.2.0", path = "../http" }
qiniu-credential = { version = "0.2.0", path = "../credential" }
qiniu-upload-token = { version = "0.2.0", path = "../upload-token" }
qiniu-reqwest = { version = "0.2.0", path = "../http-reqwest", optional = true }
qiniu-isahc = { version = "0.2.0", path = "../http-isahc", optional = true }
qiniu-ureq = { version = "0.2.0", path = "../http-ureq", optional = true }
qiniu-utils = { version = "0.2.0", path = "../utils" }
qiniu-http = { version = "0.2.1", path = "../http" }
qiniu-credential = { version = "0.2.1", path = "../credential" }
qiniu-upload-token = { version = "0.2.1", path = "../upload-token" }
qiniu-reqwest = { version = "0.2.1", path = "../http-reqwest", optional = true }
qiniu-isahc = { version = "0.2.1", path = "../http-isahc", optional = true }
qiniu-ureq = { version = "0.2.1", path = "../http-ureq", optional = true }
qiniu-utils = { version = "0.2.1", path = "../utils" }

[dev-dependencies]
async-std = { version = "1.9.0", features = ["attributes"] }
Expand Down
6 changes: 3 additions & 3 deletions http-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@

```toml
[dependencies]
qiniu-http-client = { version = "0.2.0", features = ["ureq"] }
qiniu-http-client = { version = "0.2.1", features = ["ureq"] }
```

### 启用 Isahc 异步接口

```toml
[dependencies]
qiniu-http-client = { version = "0.2.0", features = ["async", "isahc"] }
qiniu-http-client = { version = "0.2.1", features = ["async", "isahc"] }
```

### 启用 Reqwest 异步接口

```toml
[dependencies]
qiniu-http-client = { version = "0.2.0", features = ["async", "reqwest"] }
qiniu-http-client = { version = "0.2.1", features = ["async", "reqwest"] }
```

### 其他功能
Expand Down
3 changes: 2 additions & 1 deletion http-client/src/client/call/send_http_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn need_retry_after_backoff(err: &TryError) -> bool {
}

fn handle_response_error(
response_error: ResponseError,
mut response_error: ResponseError,
http_parts: &mut HttpRequestParts,
parts: &InnerRequestParts<'_>,
retried: &mut RetriedStatsInfo,
Expand All @@ -98,6 +98,7 @@ fn handle_response_error(
.build(),
);
retried.increase_current_endpoint();
response_error = response_error.set_retry_decision(retry_result.decision());
TryError::new(response_error, retry_result)
}

Expand Down
4 changes: 2 additions & 2 deletions http-client/src/client/chooser/shuffled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mod tests {
);
assert_eq!(
make_set(ip_chooser.choose(IPS_WITHOUT_PORT, Default::default())),
make_set(&[IpAddrWithPort::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 3)), None)]),
make_set([IpAddrWithPort::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 3)), None)]),
);

ip_chooser.feedback(
Expand All @@ -126,7 +126,7 @@ mod tests {
);
assert_eq!(
make_set(ip_chooser.choose(IPS_WITHOUT_PORT, Default::default())),
make_set(&[
make_set([
IpAddrWithPort::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1)), None),
IpAddrWithPort::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2)), None),
])
Expand Down
2 changes: 1 addition & 1 deletion http-client/src/client/chooser/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Chooser for SubnetChooser {
}
}
}
let chosen_ips = choose_group(subnets_map.into_iter().map(|(_, ips)| ips)).unwrap_or_default();
let chosen_ips = choose_group(subnets_map.into_values()).unwrap_or_default();
do_some_work_async(&self.inner, need_to_shrink);
return chosen_ips.into();

Expand Down
6 changes: 3 additions & 3 deletions http-client/src/client/request/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ mod sync_part {
/// 设置阻塞 Multipart 的请求体为文件
pub fn file_path<S: AsRef<OsStr> + ?Sized>(path: &S) -> IoResult<Self> {
let path = Path::new(path);
let file = File::open(&path)?;
let mut metadata = PartMetadata::default().mime(mime_guess::from_path(&path).first_or_octet_stream());
let file = File::open(path)?;
let mut metadata = PartMetadata::default().mime(mime_guess::from_path(path).first_or_octet_stream());
if let Some(file_name) = path.file_name() {
let file_name = match file_name.to_string_lossy() {
Cow::Borrowed(str) => FileName::from(str),
Expand Down Expand Up @@ -420,7 +420,7 @@ mod async_part {
pub async fn file_path<S: AsRef<OsStr> + ?Sized>(path: &S) -> IoResult<AsyncPart<'a>> {
let path = Path::new(path);
let file = File::open(&path).await?;
let mut metadata = PartMetadata::default().mime(mime_guess::from_path(&path).first_or_octet_stream());
let mut metadata = PartMetadata::default().mime(mime_guess::from_path(path).first_or_octet_stream());
if let Some(file_name) = path.file_name() {
let file_name = match file_name.to_string_lossy() {
Cow::Borrowed(str) => FileName::from(str),
Expand Down
20 changes: 19 additions & 1 deletion http-client/src/client/response/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{
super::super::{EndpointParseError, RetriedStatsInfo},
super::super::{EndpointParseError, RetriedStatsInfo, RetryDecision},
X_LOG_HEADER_NAME, X_REQ_ID_HEADER_NAME,
};
use anyhow::Error as AnyError;
Expand Down Expand Up @@ -62,6 +62,7 @@ pub struct Error {
x_headers: XHeaders,
response_body_sample: Vec<u8>,
retried: Option<RetriedStatsInfo>,
retry_decision: Option<RetryDecision>,
extensions: Extensions,
}

Expand All @@ -80,6 +81,7 @@ impl Error {
x_headers: Default::default(),
response_body_sample: Default::default(),
retried: Default::default(),
retry_decision: Default::default(),
extensions: Default::default(),
}
}
Expand All @@ -96,6 +98,7 @@ impl Error {
x_headers: Default::default(),
response_body_sample: Default::default(),
retried: Default::default(),
retry_decision: Default::default(),
extensions: Default::default(),
}
}
Expand All @@ -108,6 +111,14 @@ impl Error {
self
}

/// 设置重试决定
#[inline]
#[must_use]
pub fn set_retry_decision(mut self, retry_decision: RetryDecision) -> Self {
self.retry_decision = Some(retry_decision);
self
}

/// 设置 HTTP 响应信息
#[inline]
#[must_use]
Expand Down Expand Up @@ -152,6 +163,12 @@ impl Error {
self.kind
}

/// 获取重试决定
#[inline]
pub fn retry_decision(&self) -> Option<RetryDecision> {
self.retry_decision
}

/// 获取响应体样本
#[inline]
pub fn response_body_sample(&self) -> &[u8] {
Expand Down Expand Up @@ -214,6 +231,7 @@ impl Error {
error: err.into_inner(),
response_body_sample: Default::default(),
retried: Default::default(),
retry_decision: Default::default(),
extensions: Default::default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion http-client/src/client/retrier/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RequestRetrier for ErrorRetrier {
ResponseErrorKind::UnexpectedStatusCode(_) => RetryDecision::DontRetry,
ResponseErrorKind::StatusCodeError(status_code) => match status_code.as_u16() {
0..=399 => panic!("Should not arrive here"),
400..=501 | 579 | 599 | 608 | 612 | 614 | 616 | 618 | 630 | 631 | 632 | 640 | 701 => {
400..=499 | 501 | 579 | 608 | 612 | 614 | 616 | 618 | 630 | 631 | 632 | 640 | 701 => {
RetryDecision::DontRetry
}
509 | 573 => RetryDecision::Throttled,
Expand Down
Loading

0 comments on commit 9796bfa

Please sign in to comment.