pub trait ShardService: Sized {
// Required methods
async fn ingest_document(
self,
context: Context,
doc: Document,
) -> RpcResult<DocumentId>;
async fn tick_phase(
self,
context: Context,
phase: TickPhase,
tick: u64,
) -> RpcResult<PhaseResult>;
async fn local_query(
self,
context: Context,
req: LocalQueryRequest,
) -> RpcResult<LocalQueryResult>;
async fn get_term_frequencies(
self,
context: Context,
terms: Vec<String>,
) -> RpcResult<HashMap<String, u64>>;
async fn get_node(
self,
context: Context,
id: NodeId,
) -> RpcResult<Option<NodeData>>;
async fn health_check(self, context: Context) -> RpcResult<ShardHealth>;
async fn resolve_ghost_nodes(
self,
context: Context,
node_ids: Vec<NodeId>,
) -> RpcResult<Vec<GhostNode>>;
async fn get_neighbors(
self,
context: Context,
node_id: NodeId,
) -> RpcResult<Vec<NodeId>>;
async fn receive_signals(
self,
context: Context,
signals: Vec<CrossShardSignal>,
) -> RpcResult<()>;
// Provided method
fn serve(self) -> ServeShardService<Self> { ... }
}Expand description
Service provided by each shard in the distributed colony.
This service handles document ingestion, tick phase execution, local queries, and cross-shard coordination.
Required Methods§
Sourceasync fn ingest_document(
self,
context: Context,
doc: Document,
) -> RpcResult<DocumentId>
async fn ingest_document( self, context: Context, doc: Document, ) -> RpcResult<DocumentId>
Ingest a document into this shard.
The document will be processed by local agents during the next tick. Returns the document ID assigned to the ingested document.
Sourceasync fn tick_phase(
self,
context: Context,
phase: TickPhase,
tick: u64,
) -> RpcResult<PhaseResult>
async fn tick_phase( self, context: Context, phase: TickPhase, tick: u64, ) -> RpcResult<PhaseResult>
Execute a tick phase on this shard.
Phases are executed in order: Sense -> Act -> Decay -> Advance. Each phase must complete on all shards before the next phase begins (barrier sync).
Sourceasync fn local_query(
self,
context: Context,
req: LocalQueryRequest,
) -> RpcResult<LocalQueryResult>
async fn local_query( self, context: Context, req: LocalQueryRequest, ) -> RpcResult<LocalQueryResult>
Execute a local query (part of distributed query).
Returns matching nodes from this shard’s portion of the graph. Results are combined by the coordinator using scatter-gather.
Sourceasync fn get_term_frequencies(
self,
context: Context,
terms: Vec<String>,
) -> RpcResult<HashMap<String, u64>>
async fn get_term_frequencies( self, context: Context, terms: Vec<String>, ) -> RpcResult<HashMap<String, u64>>
Get term frequencies for global DF computation.
Returns a map of term -> document frequency for TF-IDF calculation. Used during global DF aggregation for TF-IDF scoring.
Sourceasync fn get_node(
self,
context: Context,
id: NodeId,
) -> RpcResult<Option<NodeData>>
async fn get_node( self, context: Context, id: NodeId, ) -> RpcResult<Option<NodeData>>
Fetch a node’s full data (for ghost node resolution).
Used when a shard needs detailed information about a node that exists on another shard.
Sourceasync fn health_check(self, context: Context) -> RpcResult<ShardHealth>
async fn health_check(self, context: Context) -> RpcResult<ShardHealth>
Health check.
Returns the current health status of this shard including resource usage and processing statistics.
Sourceasync fn resolve_ghost_nodes(
self,
context: Context,
node_ids: Vec<NodeId>,
) -> RpcResult<Vec<GhostNode>>
async fn resolve_ghost_nodes( self, context: Context, node_ids: Vec<NodeId>, ) -> RpcResult<Vec<GhostNode>>
Resolve cross-shard edges by fetching ghost node data.
Batch operation to fetch data for multiple nodes at once, creating ghost node representations for cross-shard edges.
Sourceasync fn get_neighbors(
self,
context: Context,
node_id: NodeId,
) -> RpcResult<Vec<NodeId>>
async fn get_neighbors( self, context: Context, node_id: NodeId, ) -> RpcResult<Vec<NodeId>>
Get the list of nodes connected to a given node.
Returns node IDs of all neighbors, including cross-shard references.
Sourceasync fn receive_signals(
self,
context: Context,
signals: Vec<CrossShardSignal>,
) -> RpcResult<()>
async fn receive_signals( self, context: Context, signals: Vec<CrossShardSignal>, ) -> RpcResult<()>
Receive cross-shard signals during the Exchange phase.
Signals from other shards are delivered here for local processing.
Provided Methods§
Sourcefn serve(self) -> ServeShardService<Self>
fn serve(self) -> ServeShardService<Self>
Returns a serving function to use with InFlightRequest::execute.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".