pub struct AccountPool {
accounts: Mutex<AccountStateMap>,
}Expand description
The account state map, behind one handle.
Fields§
§accounts: Mutex<AccountStateMap>Implementations§
Source§impl AccountPool
impl AccountPool
pub fn new(specs: &[LoadedAccount]) -> Self
Sourcepub fn empty_for_test() -> Self
pub fn empty_for_test() -> Self
Empty map for the testing feature’s Workspace::testing_stub.
pub fn all_loaded(&self) -> bool
pub fn usage(&self, display_name: &str) -> Option<UsageSnapshot>
Sourcepub fn latest_reading(&self, display_name: &str) -> Option<UsageSnapshot>
pub fn latest_reading(&self, display_name: &str) -> Option<UsageSnapshot>
The newest reading a view draws: a rate-limited response’s windows when one landed after the last successful probe, else that probe’s snapshot.
pub fn usage_error(&self, display_name: &str) -> Option<UsageFetchStatus>
pub fn auth(&self, display_name: &str) -> Option<AccountAuth>
pub fn env(&self, key: &AccountKey) -> Option<HashMap<String, String>>
pub fn provider(&self, key: &AccountKey) -> Option<Provider>
pub fn loading_state(&self, key: &AccountKey) -> LoadingState
pub fn is_saturated(&self, key: &AccountKey) -> bool
pub fn unusable_reason(&self, key: &AccountKey) -> Option<Unusable>
pub fn scheduler_should_probe(&self, key: &AccountKey) -> bool
pub fn should_probe_now(&self, key: &AccountKey) -> bool
pub fn set_usage(&self, key: &AccountKey, snapshot: UsageSnapshot)
pub fn set_loading(&self, key: &AccountKey, loading: LoadingState)
pub fn set_limit_reading(&self, key: &AccountKey, snapshot: UsageSnapshot)
pub fn set_last_error( &self, key: &AccountKey, status: UsageFetchStatus, retry_after: Option<Duration>, )
pub fn clear_last_error(&self, key: &AccountKey)
pub fn disarm_override(&self, key: &AccountKey)
pub fn seed_from_cache(&self, cached: &BTreeMap<String, UsageSnapshot>)
pub fn snapshots_for_cache(&self) -> BTreeMap<String, UsageSnapshot>
pub fn account_names(&self) -> Vec<String>
Sourcepub fn ordered_account_keys(&self) -> Vec<AccountKey>
pub fn ordered_account_keys(&self) -> Vec<AccountKey>
The account keys in declaration order.
Sourcepub fn next_probe_after(&self, key: &AccountKey) -> Option<Duration>
pub fn next_probe_after(&self, key: &AccountKey) -> Option<Duration>
How long until the account’s next scheduled probe, when one is pending.
Sourcepub fn probe_entries(
&self,
) -> Vec<(AccountKey, Provider, HashMap<String, String>)>
pub fn probe_entries( &self, ) -> Vec<(AccountKey, Provider, HashMap<String, String>)>
The poller’s work list: every account due a probe, with its provider and env.
Sourcepub fn disarm_backoff_overrides(&self, keys: &[AccountKey])
pub fn disarm_backoff_overrides(&self, keys: &[AccountKey])
Disarm the one-shot reset-clear override for accounts whose backoff is genuinely active.
Sourcepub fn select_account(
&self,
pin: &OrgPin,
org: &str,
model: &str,
) -> Result<AccountKey, SelectionError>
pub fn select_account( &self, pin: &OrgPin, org: &str, model: &str, ) -> Result<AccountKey, SelectionError>
Run the declared-model selection walk for one org pin.
Sourcepub fn declares(&self, key: &AccountKey, model: &str) -> bool
pub fn declares(&self, key: &AccountKey, model: &str) -> bool
true when the account serves model. An unknown account
serves nothing.
Sourcepub fn model_slug_for(
&self,
key: &AccountKey,
canonical: &str,
) -> Option<String>
pub fn model_slug_for( &self, key: &AccountKey, canonical: &str, ) -> Option<String>
The upstream slug the account maps canonical to, when the
account declares a different upstream spelling. None forwards
the canonical name unchanged.
Sourcepub fn set_model_slug(&self, key: &AccountKey, canonical: &str, slug: &str)
pub fn set_model_slug(&self, key: &AccountKey, canonical: &str, slug: &str)
Set a slug mapping on one account. Test setup only - production slugs arrive through the config-loaded state map.
Sourcepub fn provider_and_env(
&self,
key: &AccountKey,
) -> Option<(Provider, HashMap<String, String>)>
pub fn provider_and_env( &self, key: &AccountKey, ) -> Option<(Provider, HashMap<String, String>)>
The provider and env of one account, for credential resolution.
Sourcepub fn replace_state_for_test(&self, map: AccountStateMap)
pub fn replace_state_for_test(&self, map: AccountStateMap)
Replace the whole state map. Test fixture setup only.
Sourcepub fn replace_accounts(&self, specs: &[LoadedAccount])
pub fn replace_accounts(&self, specs: &[LoadedAccount])
Replace the account set with one a config reload produced.
Health for an account present in both sets is carried across: a
reload is not a reason to blank the usage bars, and resetting a
terminal LoadingState would make a ready account unspawnable until
its next probe. An account new to the set starts Loading.