pub struct FileCredential { /* private fields */ }Expand description
Reads a token file at construction and after its modification time or size changes.
File metadata is checked at most once per second. Surrounding whitespace is removed. If the file becomes empty or unreadable, requests fail until a later check succeeds; no stale token is sent. The constructor fails when the initial file is unreadable or empty. Checks and reads use a mutex, briefly serializing concurrent callers. Use a local filesystem; slow network filesystems can delay calls. Replace the token atomically by writing a temporary file and renaming it. An empty or partial token can fail pull stream opens, which back off for about one minute.
use std::sync::Arc;
use dex_sdk::{ClientOptions, FileCredential, WorkerOptions};
let credential = Arc::new(FileCredential::new("/var/run/secrets/dex/token")?);
let client_options = ClientOptions::new().credential(credential.clone());
let worker_options = WorkerOptions::new().credential(credential);Implementations§
Trait Implementations§
Source§impl Credential for FileCredential
impl Credential for FileCredential
Auto Trait Implementations§
impl !Freeze for FileCredential
impl Forget for FileCredential
impl RefUnwindSafe for FileCredential
impl Send for FileCredential
impl Sync for FileCredential
impl Unpin for FileCredential
impl UnsafeUnpin for FileCredential
impl UnwindSafe for FileCredential
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> 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