mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-24 02:45:07 +01:00
doc(tokio): Set keep_alive to false on hyper clients.
This prevents hanging event loops.
This commit is contained in:
@@ -11,8 +11,9 @@ fn main() {
|
||||
let creds = yup_oauth2::read_application_secret(path::Path::new("clientsecret.json"))
|
||||
.expect("clientsecret");
|
||||
let https = HttpsConnector::new(1).expect("tls");
|
||||
let client = Client::builder().build::<_, hyper::Body>(https);
|
||||
|
||||
let client = Client::builder()
|
||||
.keep_alive(false)
|
||||
.build::<_, hyper::Body>(https);
|
||||
let scopes = &["https://www.googleapis.com/auth/youtube.readonly".to_string()];
|
||||
|
||||
let ad = yup_oauth2::DefaultFlowDelegate;
|
||||
|
||||
@@ -9,7 +9,9 @@ use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let https = HttpsConnector::new(1).expect("tls");
|
||||
let client = Client::builder().build::<_, hyper::Body>(https);
|
||||
let client = Client::builder()
|
||||
.keep_alive(false)
|
||||
.build::<_, hyper::Body>(https);
|
||||
let ad = yup_oauth2::DefaultFlowDelegate;
|
||||
let secret = yup_oauth2::read_application_secret(Path::new("clientsecret.json"))
|
||||
.expect("clientsecret.json");
|
||||
@@ -35,6 +37,5 @@ fn main() {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(fut).unwrap();
|
||||
tokio::run(fut)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ fn main() {
|
||||
let creds =
|
||||
yup_oauth2::service_account_key_from_file(path::Path::new("serviceaccount.json")).unwrap();
|
||||
let https = HttpsConnector::new(1).expect("tls");
|
||||
let client = Client::builder().build::<_, hyper::Body>(https);
|
||||
let client = Client::builder()
|
||||
.keep_alive(false)
|
||||
.build::<_, hyper::Body>(https);
|
||||
|
||||
let mut sa = yup_oauth2::ServiceAccountAccess::new(creds, client);
|
||||
|
||||
@@ -29,7 +31,6 @@ fn main() {
|
||||
println!("cached token is {:?} and should be identical", tok);
|
||||
Ok(())
|
||||
});
|
||||
let all = fut.join(fut2);
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(all).unwrap();
|
||||
let all = fut.join(fut2).then(|_| Ok(()));
|
||||
tokio::run(all)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user