Crates.io | adventure |
lib.rs | adventure |
version | 0.5.0 |
source | src |
created_at | 2019-03-21 19:19:02.697186 |
updated_at | 2020-01-08 14:39:06.345327 |
description | Helps your great adventure for the various type of requests. |
homepage | |
repository | https://github.com/spoqa/adventure |
max_upload_size | |
id | 122936 |
size | 38,070 |
Provides general utilities for the web requests, like exponential backoff and pagination.
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(())
}),
);
}