Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Remove `reqwest-retry` dependency in favor of `tokio-retry2` ([#21](https://github.com/stjude-rust-labs/tes/pull/21)).
- Fix serialization of optional values in request and response types ([#19](https://github.com/stjude-rust-labs/tes/pull/19)).

## 0.8.0 - 06-04-2025
Expand Down
53 changes: 25 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@ homepage = "https://github.com/stjude-rust-labs/tes"
repository = "https://github.com/stjude-rust-labs/tes"
rust-version = "1.82.0"

[dependencies]
# `anyhow` is required because `reqwest_middleware` uses `anyhow::Result` as one
# of its return types. The main error crates used within `tes` is `miette`.
anyhow = { version = "1.0.98", optional = true }
chrono = { version = "0.4.40", features = ["serde"] }
miette = { version = "7.5.0", optional = true }
reqwest = { version = "0.12.15", features = ["json"] }
reqwest-middleware = "0.4.2"
reqwest-retry = "0.7.0"
serde = { version = "1.0.219", features = ["derive"], optional = true }
serde_json = { version = "1.0.140" }
serde_url_params = { version = "0.2.1", optional = true }
thiserror = "2.0.12"
tokio = { version = "1.44.2", features = ["full", "time"] }
tracing = "0.1.41"
url = { version = "2.5.4", features = ["serde"], optional = true }
base64 = "0.22"

[dev-dependencies]
pretty_assertions = "1.4.1"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
[package.metadata.docs.rs]
all-features = true

[features]
default = ["types"]
client = [
"dep:reqwest",
"dep:serde_url_params",
"dep:tokio-retry2",
"dep:tracing",
"dep:url",
"serde",
"dep:anyhow",
"dep:miette",
"types",
"dep:url",
"dep:serde_url_params",
]
ord = []
serde = ["dep:serde"]
types = ["dep:url"]

[dependencies]
chrono = { version = "0.4.41", features = ["serde"] }
reqwest = { version = "0.12.23", features = ["json"], optional = true }
serde = { version = "1.0.219", features = ["derive"], optional = true }
serde_json = { version = "1.0.143" }
serde_url_params = { version = "0.2.1", optional = true }
thiserror = "2.0.15"
tokio-retry2 = { version = "0.5.7", optional = true }
tracing = { version = "0.1.41", optional = true }
url = { version = "2.5.4", features = ["serde"], optional = true }

[dev-dependencies]
base64 = "0.22"
miette = "7.6.0"
pretty_assertions = "1.4.1"
tokio = { version = "1.47.1", features = ["full", "time"] }
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }

[[example]]
name = "simple"
required-features = ["client", "serde"]
Expand Down Expand Up @@ -77,6 +77,3 @@ broken_intra_doc_links = "warn"

[lints.clippy]
missing_docs_in_private_items = "warn"

[package.metadata.docs.rs]
all-features = true
8 changes: 7 additions & 1 deletion examples/service-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use miette::Context as _;
use miette::IntoDiagnostic;
use miette::Result;
use tes::v1::client;
use tes::v1::client::strategy::ExponentialFactorBackoff;
use tes::v1::client::strategy::MaxInterval;
use tracing_subscriber::EnvFilter;

/// The environment variable for a basic auth username.
Expand Down Expand Up @@ -52,10 +54,14 @@ async fn main() -> Result<()> {

let client = builder.try_build().expect("could not build client");

let retries = ExponentialFactorBackoff::from_millis(1000, 2.0)
.max_interval(10000)
.take(3);

println!(
"{:#?}",
client
.service_info()
.service_info(retries)
.await
.into_diagnostic()
.context("getting the service information")?
Expand Down
8 changes: 7 additions & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! `cargo run --release --features=client,serde --example simple <URL>`

use tes::v1::client;
use tes::v1::client::strategy::ExponentialFactorBackoff;
use tes::v1::client::strategy::MaxInterval;

#[tokio::main]
async fn main() {
Expand All @@ -16,10 +18,14 @@ async fn main() {
.try_build()
.expect("could not build client");

let retries = ExponentialFactorBackoff::from_millis(1000, 2.0)
.max_interval(10000)
.take(3);

println!(
"{:#?}",
client
.service_info()
.service_info(retries)
.await
.expect("getting service information failed")
);
Expand Down
8 changes: 7 additions & 1 deletion examples/task-get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use miette::Context as _;
use miette::IntoDiagnostic;
use miette::Result;
use tes::v1::client::Client;
use tes::v1::client::strategy::ExponentialFactorBackoff;
use tes::v1::client::strategy::MaxInterval;
use tes::v1::types::requests::GetTaskParams;
use tes::v1::types::requests::View;
use tracing_subscriber::EnvFilter;
Expand Down Expand Up @@ -53,10 +55,14 @@ async fn main() -> Result<()> {

let client = builder.try_build().expect("could not build client");

let retries = ExponentialFactorBackoff::from_millis(1000, 2.0)
.max_interval(10000)
.take(3);

println!(
"{:#?}",
client
.get_task(id, Some(&GetTaskParams { view: View::Full }))
.get_task(id, Some(&GetTaskParams { view: View::Full }), retries)
.await
.into_diagnostic()
.context("getting a task")?
Expand Down
19 changes: 14 additions & 5 deletions examples/task-list-all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use miette::Context as _;
use miette::IntoDiagnostic;
use miette::Result;
use tes::v1::client::Client;
use tes::v1::client::strategy::ExponentialFactorBackoff;
use tes::v1::client::strategy::MaxInterval;
use tes::v1::types::requests::ListTasksParams;
use tes::v1::types::requests::View;
use tracing_subscriber::EnvFilter; // Import the Engine trait
Expand All @@ -30,12 +32,19 @@ async fn list_all_tasks(client: &Client) -> Result<()> {
let mut last_token = None;

loop {
let retries = ExponentialFactorBackoff::from_millis(1000, 2.0)
.max_interval(10000)
.take(3);

let response = client
.list_tasks(Some(&ListTasksParams {
view: Some(View::Full),
page_token: last_token,
..Default::default()
}))
.list_tasks(
Some(&ListTasksParams {
view: Some(View::Full),
page_token: last_token,
..Default::default()
}),
retries,
)
.await
.into_diagnostic()
.context("listing tasks")?;
Expand Down
8 changes: 7 additions & 1 deletion examples/task-submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use miette::Context as _;
use miette::IntoDiagnostic;
use miette::Result;
use tes::v1::client;
use tes::v1::client::strategy::ExponentialFactorBackoff;
use tes::v1::client::strategy::MaxInterval;
use tes::v1::types::requests::Task;
use tes::v1::types::task::Executor;
use tes::v1::types::task::Resources;
Expand Down Expand Up @@ -73,10 +75,14 @@ async fn main() -> Result<()> {
..Default::default()
};

let retries = ExponentialFactorBackoff::from_millis(1000, 2.0)
.max_interval(10000)
.take(3);

println!(
"{:#?}",
client
.create_task(&task)
.create_task(&task, retries)
.await
.into_diagnostic()
.context("submitting a task")?
Expand Down
Loading