pub struct RefreshTokenSource { /* private fields */ }Expand description
A TokenSource automatically refreshing the token before it expires.
Implementations§
Source§impl RefreshTokenSource
impl RefreshTokenSource
Sourcepub fn builder<T>(
name: impl Into<String>,
token_refresher: T,
) -> RefreshTokenSourceBuilder<T>where
T: TokenRefresher,
pub fn builder<T>(
name: impl Into<String>,
token_refresher: T,
) -> RefreshTokenSourceBuilder<T>where
T: TokenRefresher,
Creates a builder for a RefreshTokenSource.
Sourcepub fn new(
name: String,
token_refresher: impl TokenRefresher,
refresh_retry_delay: Duration,
refresh_threshold: Duration,
min_token_lifetime: Duration,
initial_token: Option<TokenWithExpiry>,
) -> RefreshTokenSource
pub fn new( name: String, token_refresher: impl TokenRefresher, refresh_retry_delay: Duration, refresh_threshold: Duration, min_token_lifetime: Duration, initial_token: Option<TokenWithExpiry>, ) -> RefreshTokenSource
Creates a new RefreshTokenSource.
§Arguments
name- Name of the token source, used for logging.refresh_function- Function to refresh the token.refresh_retry_delay- Delay between retries if the refresh function fails.refresh_threshold- Duration before the token’s expiry when a refresh should be attempted.refresh_timeout- Duration to wait for a refresh to complete whenget_tokenis called.initial_token- Optional pre-fetched token to publish immediately on startup.
Trait Implementations§
Source§impl TokenSource for RefreshTokenSource
impl TokenSource for RefreshTokenSource
Source§fn watch(
&self,
) -> Receiver<Option<Result<String, Box<dyn Error + Send + Sync>>>>
fn watch( &self, ) -> Receiver<Option<Result<String, Box<dyn Error + Send + Sync>>>>
Returns a watch receiver that always holds the latest valid token. Read more
Auto Trait Implementations§
impl Freeze for RefreshTokenSource
impl !RefUnwindSafe for RefreshTokenSource
impl Send for RefreshTokenSource
impl Sync for RefreshTokenSource
impl Unpin for RefreshTokenSource
impl UnsafeUnpin for RefreshTokenSource
impl !UnwindSafe for RefreshTokenSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request