https://github.com/spoqa/adventure
Helps your great adventure for the various type of requests.
https://github.com/spoqa/adventure
Last synced: about 1 year ago
JSON representation
Helps your great adventure for the various type of requests.
- Host: GitHub
- URL: https://github.com/spoqa/adventure
- Owner: spoqa
- License: apache-2.0
- Created: 2019-03-21T12:55:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T03:34:13.000Z (over 6 years ago)
- Last Synced: 2025-06-24T02:41:35.564Z (about 1 year ago)
- Language: Rust
- Size: 117 KB
- Stars: 11
- Watchers: 18
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE_APACHE
Awesome Lists containing this project
README
Adventure
=========
[![crates.io][b/crates/i]][b/crates] [![docs.rs][b/docs/i]][b/docs]
[b/crates]: https://crates.io/crates/adventure
[b/crates/i]: https://meritbadge.herokuapp.com/adventure
[b/docs]: https://docs.rs/adventure/
[b/docs/i]: https://docs.rs/adventure/badge.svg
Provides general utilities for the web requests, like [exponential backoff][] and pagination.
[exponential backoff]: https://en.wikipedia.org/wiki/Exponential_backoff
Examples
--------
```rust
use std::sync::Arc;
use adventure::prelude::*;
use futures::prelude::*;
use adventure_rusoto_ecs::AwsEcs;
use rusoto_core::Region;
use rusoto_ecs::{EcsClient, ListServicesRequest};
fn main() {
let client = EcsClient::new(Region::default());
let req = ListServicesRequest {
cluster: Some("MyEcsCluster".to_owned()),
..Default::default()
};
tokio::run(
// prepare a request
AwsEcs::from(req)
// backoff if server error is occured
.retry()
// repeat to retrieve all results
.paginate(Arc::new(client))
// compatible with futures
.for_each(|page| {
for service in page.service_arns.unwrap_or_else(Vec::new) {
println!("{}", service);
}
Ok(())
})
.or_else(|err| {
eprintln!("Error occured: {}", err);
Ok(())
}),
);
}
```