pub trait CoordinatorService: Sized {
// Required methods
async fn register(
self,
context: Context,
info: ShardInfo,
) -> RpcResult<ShardId>;
async fn unregister(
self,
context: Context,
shard_id: ShardId,
) -> RpcResult<()>;
async fn phase_complete(
self,
context: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<()>;
async fn route_document(
self,
context: Context,
doc_id: DocumentId,
) -> ShardId;
async fn route_node(self, context: Context, node_id: NodeId) -> ShardId;
async fn get_global_df(
self,
context: Context,
terms: Vec<String>,
) -> RpcResult<HashMap<String, u64>>;
async fn barrier_ready(
self,
context: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<bool>;
async fn current_tick(self, context: Context) -> u64;
async fn list_shards(self, context: Context) -> Vec<ShardInfo>;
async fn start_tick(self, context: Context) -> RpcResult<u64>;
async fn tick_status(self, context: Context) -> RpcResult<TickStatus>;
// Provided method
fn serve(self) -> ServeCoordinatorService<Self> { ... }
}Expand description
Service provided by the coordinator.
The coordinator manages shard registration, tick synchronization, query distribution, and global state aggregation.
Required Methods§
Sourceasync fn register(self, context: Context, info: ShardInfo) -> RpcResult<ShardId>
async fn register(self, context: Context, info: ShardInfo) -> RpcResult<ShardId>
Register a new shard with the coordinator.
Returns the assigned shard ID. The coordinator will include this shard in subsequent tick coordination.
Sourceasync fn unregister(self, context: Context, shard_id: ShardId) -> RpcResult<()>
async fn unregister(self, context: Context, shard_id: ShardId) -> RpcResult<()>
Unregister a shard from the coordinator.
Should be called during graceful shutdown. The coordinator will stop routing requests to this shard.
Sourceasync fn phase_complete(
self,
context: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<()>
async fn phase_complete( self, context: Context, shard_id: ShardId, phase: TickPhase, tick: u64, ) -> RpcResult<()>
Report that a shard has completed a tick phase.
Used for barrier synchronization. The coordinator tracks completion across all shards before advancing to the next phase.
Sourceasync fn route_document(self, context: Context, doc_id: DocumentId) -> ShardId
async fn route_document(self, context: Context, doc_id: DocumentId) -> ShardId
Get the shard responsible for a document.
Uses consistent hashing to determine which shard owns a document.
Sourceasync fn route_node(self, context: Context, node_id: NodeId) -> ShardId
async fn route_node(self, context: Context, node_id: NodeId) -> ShardId
Get the shard responsible for a node.
Uses consistent hashing based on node ID.
Sourceasync fn get_global_df(
self,
context: Context,
terms: Vec<String>,
) -> RpcResult<HashMap<String, u64>>
async fn get_global_df( self, context: Context, terms: Vec<String>, ) -> RpcResult<HashMap<String, u64>>
Get global document frequencies for TF-IDF.
Returns aggregated term frequencies across all shards.
Sourceasync fn barrier_ready(
self,
context: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<bool>
async fn barrier_ready( self, context: Context, shard_id: ShardId, phase: TickPhase, tick: u64, ) -> RpcResult<bool>
Signal ready for next phase (barrier).
Returns true when all shards are ready and the phase can proceed.
Sourceasync fn current_tick(self, context: Context) -> u64
async fn current_tick(self, context: Context) -> u64
Get current tick number.
Returns the global tick counter maintained by the coordinator.
Sourceasync fn list_shards(self, context: Context) -> Vec<ShardInfo>
async fn list_shards(self, context: Context) -> Vec<ShardInfo>
Get all registered shards.
Returns information about all shards in the cluster.
Sourceasync fn start_tick(self, context: Context) -> RpcResult<u64>
async fn start_tick(self, context: Context) -> RpcResult<u64>
Request to start a new tick.
Only succeeds if no tick is currently in progress.
Sourceasync fn tick_status(self, context: Context) -> RpcResult<TickStatus>
async fn tick_status(self, context: Context) -> RpcResult<TickStatus>
Get the status of the current tick.
Returns the current phase and which shards have completed it.
Provided Methods§
Sourcefn serve(self) -> ServeCoordinatorService<Self>
fn serve(self) -> ServeCoordinatorService<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".