pub struct Federation {
pub connectors: Vec<Arc<Connector>>,
}Expand description
Manages multiple remote connectors for federated queries.
Fields§
§connectors: Vec<Arc<Connector>>Implementations§
Source§impl Federation
impl Federation
Sourcepub fn add(&mut self, config: ConnectorConfig)
pub fn add(&mut self, config: ConnectorConfig)
Add a connector for a remote Haystack server.
Sourcepub async fn sync_one(&self, name: &str) -> Result<usize, String>
pub async fn sync_one(&self, name: &str) -> Result<usize, String>
Sync a single connector by name, returning the entity count on success.
Sourcepub async fn sync_all(&self) -> Vec<(String, Result<usize, String>)>
pub async fn sync_all(&self) -> Vec<(String, Result<usize, String>)>
Sync all connectors, returning a vec of (name, result) pairs.
Each result is either Ok(count) with the number of entities synced,
or Err(message) with the error description.
Sourcepub fn all_cached_entities(&self) -> Vec<HDict>
pub fn all_cached_entities(&self) -> Vec<HDict>
Returns all cached entities from all connectors, merged into a single vec.
Sourcepub fn connector_count(&self) -> usize
pub fn connector_count(&self) -> usize
Returns the number of connectors.
Sourcepub fn owner_of(&self, id: &str) -> Option<&Arc<Connector>>
pub fn owner_of(&self, id: &str) -> Option<&Arc<Connector>>
Returns the connector that owns the entity with the given ID, if any.
Sourcepub fn from_toml_str(toml_str: &str) -> Result<Self, String>
pub fn from_toml_str(toml_str: &str) -> Result<Self, String>
Parse a TOML string into a Federation, adding each connector defined
under [connectors.<key>].
Sourcepub fn from_toml_file(path: &str) -> Result<Self, String>
pub fn from_toml_file(path: &str) -> Result<Self, String>
Read a TOML file from disk and parse it into a Federation.
Sourcepub fn start_background_sync(&self) -> Vec<JoinHandle<()>>
pub fn start_background_sync(&self) -> Vec<JoinHandle<()>>
Start background sync tasks for all connectors.
Each connector gets its own tokio task that loops at its configured sync interval, reconnecting automatically on failure. Returns the join handles (they run until the server shuts down).