Struct aliri_tokens::TokenWatcher [−][src]
pub struct TokenWatcher { /* fields omitted */ }
Expand description
A token watcher that can be uses to obtain up-to-date tokens
Implementations
impl TokenWatcher
[src]
impl TokenWatcher
[src]pub async fn spawn_from_token_source<S, J>(
token_source: S,
jitter_source: J,
backoff_config: ErrorBackoffConfig
) -> Result<Self, S::Error> where
S: AsyncTokenSource + 'static,
J: JitterSource + Send + 'static,
[src]
pub async fn spawn_from_token_source<S, J>(
token_source: S,
jitter_source: J,
backoff_config: ErrorBackoffConfig
) -> Result<Self, S::Error> where
S: AsyncTokenSource + 'static,
J: JitterSource + Send + 'static,
[src]Spawns a new token watcher which will automatically and periodically refresh the token from a token source
The token will be refreshed when it becomes stale. The token’s stale time will be
jittered by jitter_source
so that multiple instances don’t stampede at the same time.
This jittering also has the benefit of potentially allowing an update from one instance to be shared within a caching layer, thus preventing multiple requests to the ultimate token authority.
pub async fn spawn_from_token_source_with_clock<S, J, C>(
token_source: S,
jitter_source: J,
backoff_config: ErrorBackoffConfig,
clock: C
) -> Result<Self, S::Error> where
S: AsyncTokenSource + 'static,
J: JitterSource + Send + 'static,
C: Clock + Send + 'static,
[src]
pub async fn spawn_from_token_source_with_clock<S, J, C>(
token_source: S,
jitter_source: J,
backoff_config: ErrorBackoffConfig,
clock: C
) -> Result<Self, S::Error> where
S: AsyncTokenSource + 'static,
J: JitterSource + Send + 'static,
C: Clock + Send + 'static,
[src]Spawns a new token watcher using the given clock
pub async fn changed(&mut self) -> Result<(), TokenPublisherQuit>
[src]
pub async fn changed(&mut self) -> Result<(), TokenPublisherQuit>
[src]A future that returns as ready whenever a new token is published
If the publisher is ever dropped, then this function will return an error indicating that no new tokens will be published.
pub fn token(&self) -> BorrowedToken<'_>
[src]
pub fn token(&self) -> BorrowedToken<'_>
[src]Borrows the current valid token
This borrow should be short-lived as outstanding borrows will block the publisher being able to report new tokens.
Trait Implementations
impl Clone for TokenWatcher
[src]
impl Clone for TokenWatcher
[src]fn clone(&self) -> TokenWatcher
[src]
fn clone(&self) -> TokenWatcher
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for TokenWatcher
impl Send for TokenWatcher
impl Sync for TokenWatcher
impl Unpin for TokenWatcher
impl !UnwindSafe for TokenWatcher
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,