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]

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]

Spawns a new token watcher using the given clock

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]

Borrows the current valid token

This borrow should be short-lived as outstanding borrows will block the publisher being able to report new tokens.

pub async fn watch<X: Fn(TokenWithLifetime) -> F, F: Future<Output = ()> + 'static>(
    self,
    sink: X
)
[src]

Runs a given asynchronous function whenever a new token update is provided

Loops forever so long as the publisher is still alive.

Trait Implementations

impl Clone for 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]

Performs copy-assignment from source. Read more

impl Debug for TokenWatcher[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[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]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 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<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V