fix(ServiceAccount): Make cache behavior more intuitive.

Now the cache is only checked for a token when the future is polled, not
at future creation time.

This also allows for reverting c2b41c3.
This commit is contained in:
Lewin Bormann
2019-06-21 18:39:51 +02:00
parent e0f3298904
commit c321f6d2e6
2 changed files with 51 additions and 41 deletions

View File

@@ -25,15 +25,12 @@ fn main() {
println!("token is: {:?}", tok);
Ok(())
});
let mut sa2 = sa.clone();
let all = fut
.then(move |_| {
sa2.token(["https://www.googleapis.com/auth/pubsub"].iter())
.and_then(|tok| {
println!("cached token is {:?} and should be identical", tok);
Ok(())
})
})
.then(|_| Ok(()));
let fut2 = sa
.token(["https://www.googleapis.com/auth/pubsub"].iter())
.and_then(|tok| {
println!("cached token is {:?} and should be identical", tok);
Ok(())
});
let all = fut.join(fut2).then(|_| Ok(()));
tokio::run(all)
}