pub struct CredentialPool { /* private fields */ }Expand description
Pool of credentials per provider with round-robin selection and failover.
Implementations§
Source§impl CredentialPool
impl CredentialPool
pub fn new() -> Self
Sourcepub fn from_auth_store(auth: &AuthStore) -> Self
pub fn from_auth_store(auth: &AuthStore) -> Self
Create a pool pre-loaded from an AuthStore’s credentials.
Sourcepub fn add(&self, provider: &str, api_key: String, base_url: Option<String>)
pub fn add(&self, provider: &str, api_key: String, base_url: Option<String>)
Add a credential for a provider.
Sourcepub fn get(&self, provider: &str) -> Option<CredentialEntry>
pub fn get(&self, provider: &str) -> Option<CredentialEntry>
Get the next available credential for a provider using round-robin.
Returns None if no credentials are registered or all are in cooldown.
Sourcepub fn report_rate_limit(
&self,
provider: &str,
api_key: &str,
retry_after: Option<u64>,
)
pub fn report_rate_limit( &self, provider: &str, api_key: &str, retry_after: Option<u64>, )
Report that a credential hit a rate limit.
Sourcepub fn report_success(&self, provider: &str, api_key: &str)
pub fn report_success(&self, provider: &str, api_key: &str)
Report that a credential was used successfully.
Sourcepub fn available_count(&self, provider: &str) -> usize
pub fn available_count(&self, provider: &str) -> usize
Get the number of available (non-cooldown) credentials for a provider.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CredentialPool
impl RefUnwindSafe for CredentialPool
impl Send for CredentialPool
impl Sync for CredentialPool
impl Unpin for CredentialPool
impl UnsafeUnpin for CredentialPool
impl UnwindSafe for CredentialPool
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