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 filter_cached_entities(
&self,
filter_expr: &str,
limit: usize,
) -> Result<Vec<HDict>, String>
pub fn filter_cached_entities( &self, filter_expr: &str, limit: usize, ) -> Result<Vec<HDict>, String>
Filter cached entities across all connectors using bitmap-accelerated queries.
Each connector uses its own bitmap tag index for fast filtering, then results are merged up to the given limit. Much faster than linear scan for tag-based queries over large federated entity sets.
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 batch_read_by_id<'a>(
&self,
ids: impl IntoIterator<Item = &'a str>,
) -> (Vec<HDict>, Vec<String>)
pub fn batch_read_by_id<'a>( &self, ids: impl IntoIterator<Item = &'a str>, ) -> (Vec<HDict>, Vec<String>)
Batch read entities by ID across federated connectors.
Groups IDs by owning connector and fetches each group in a single
indexed lookup (O(1) per ID via cache_id_map), avoiding repeated
linear scans. Returns (found_entities, missing_ids).
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).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Federation
impl !RefUnwindSafe for Federation
impl Send for Federation
impl Sync for Federation
impl Unpin for Federation
impl UnsafeUnpin for Federation
impl !UnwindSafe for Federation
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more