pub struct EndpointList { /* private fields */ }Expand description
The ordered endpoint list with the sticky-primary active cursor.
Implementations§
Source§impl EndpointList
impl EndpointList
Sourcepub fn parse(
uri: &str,
default_token: Option<String>,
) -> Result<EndpointList, IntelError>
pub fn parse( uri: &str, default_token: Option<String>, ) -> Result<EndpointList, IntelError>
Parse the comma-list uri into an ordered EndpointList, resolving each
endpoint’s credential. default_token — the already-resolved
--intelligence-token or its _FILE form — supplies endpoint 1’s value
when its env override is unset, and applies to endpoint 1 only.
Per-endpoint env overrides (AGENTD_INTELLIGENCE_TOKEN_<N> / _FILE)
win when present.
Sourcepub fn parse_with_env(
uri: &str,
default_token: Option<String>,
env: &dyn Fn(&str) -> Option<String>,
) -> Result<EndpointList, IntelError>
pub fn parse_with_env( uri: &str, default_token: Option<String>, env: &dyn Fn(&str) -> Option<String>, ) -> Result<EndpointList, IntelError>
parse with an injectable env reader (for tests).
Sourcepub fn set_extra_headers(&mut self, headers: Vec<(String, String)>)
pub fn set_extra_headers(&mut self, headers: Vec<(String, String)>)
Apply the configured intelligence.headers to every endpoint. Called
once after construction, before any dial.
Sourcepub fn set_signer(&mut self, signer: Arc<dyn RequestSigner>)
pub fn set_signer(&mut self, signer: Arc<dyn RequestSigner>)
Attach a per-request AWS SigV4 signer to every endpoint in the list.
Sourcepub fn set_provider(&mut self, provider: Provider)
pub fn set_provider(&mut self, provider: Provider)
Select the wire dialect for every endpoint from intelligence.dialect.
A host-only endpoint resolved its path with the OpenAI default before the
dialect was known, so a still-defaulted path is re-pointed at the chosen
dialect’s default. A path the operator wrote explicitly is left untouched,
because they may be routing through a gateway mount. Bedrock overrides the
path per request in any case.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn active(&self) -> usize
pub fn breaker_config(&self) -> &BreakerConfig
pub fn ep(&self, idx: usize) -> &Endpoint
pub fn iter(&self) -> impl Iterator<Item = &Endpoint>
Sourcepub fn attempt_order(&self) -> Vec<usize>
pub fn attempt_order(&self) -> Vec<usize>
The failover attempt order: the active index first, then the
remaining endpoints in ascending list order, skipping any whose breaker is
OPEN and still cooling. available promotes an endpoint whose cooldown
has elapsed to HALF-OPEN, so it is probed here rather than skipped
forever. An empty result means every endpoint is down.
Sourcepub fn prefer_lowest_healthy(&mut self) -> Option<usize>
pub fn prefer_lowest_healthy(&mut self) -> Option<usize>
Snap active back to the lowest-index endpoint whose breaker is not OPEN.
This is what makes the primary sticky: once it re-closes, the next call
returns to it, so serving from a fallback is temporary by construction and
a list never silently drifts onto its last entry. Returns the new active
index if it changed.
Sourcepub fn set_active(&mut self, idx: usize) -> Option<usize>
pub fn set_active(&mut self, idx: usize) -> Option<usize>
Mark idx as the active endpoint (it just succeeded). Returns the new
active index if it changed.
Sourcepub fn all_down(&self) -> bool
pub fn all_down(&self) -> bool
True when no endpoint is available, i.e. every breaker is OPEN and still cooling.
Sourcepub fn active_identity(&self) -> (usize, &'static str)
pub fn active_identity(&self) -> (usize, &'static str)
The active endpoint’s bounded structural identity (index, transport-scheme) for the child→supervisor
crate::subagent::protocol::AgentMsg::IntelHealth report. Transport and
index ONLY — never the URL, host, cid or credential — matching the
redaction the served resource body applies, so neither route can leak
what the other withholds.
Sourcepub fn body(&self, model: Option<&str>) -> Value
pub fn body(&self, model: Option<&str>) -> Value
The agentd://intelligence resource body: the endpoint list by transport
and index, which one is active, and each one’s health — state, latency
and error rate. It must contain no secret and no URL: only the bounded
structural transport and addr (a bare host[:port], which cannot
carry a scheme-borne credential) plus the live health atomics. Anything
added here becomes readable by every holder of the resource.