pub struct CoordinatorServer { /* private fields */ }Expand description
Server implementation for the coordinator.
CoordinatorServer wraps a Coordinator and implements the CoordinatorService
trait, allowing shards and clients to interact with the coordinator via tarpc RPC.
§Thread Safety
The coordinator is wrapped in Arc as it uses interior mutability
(RwLock, AtomicU64) for thread-safe access.
§Example
ⓘ
use phago_distributed::rpc::server::CoordinatorServer;
use phago_distributed::coordinator::Coordinator;
let coordinator = Arc::new(Coordinator::new(3));
let server = CoordinatorServer::new(coordinator);
server.serve("127.0.0.1:8080".parse().unwrap()).await?;Implementations§
Source§impl CoordinatorServer
impl CoordinatorServer
Sourcepub fn new(coordinator: Arc<Coordinator>) -> Self
pub fn new(coordinator: Arc<Coordinator>) -> Self
Trait Implementations§
Source§impl Clone for CoordinatorServer
impl Clone for CoordinatorServer
Source§fn clone(&self) -> CoordinatorServer
fn clone(&self) -> CoordinatorServer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CoordinatorService for CoordinatorServer
impl CoordinatorService for CoordinatorServer
Source§async fn register(self, _ctx: Context, info: ShardInfo) -> RpcResult<ShardId>
async fn register(self, _ctx: Context, info: ShardInfo) -> RpcResult<ShardId>
Register a new shard with the coordinator. Read more
Source§async fn unregister(self, _ctx: Context, shard_id: ShardId) -> RpcResult<()>
async fn unregister(self, _ctx: Context, shard_id: ShardId) -> RpcResult<()>
Unregister a shard from the coordinator. Read more
Source§async fn phase_complete(
self,
_ctx: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<()>
async fn phase_complete( self, _ctx: Context, shard_id: ShardId, phase: TickPhase, tick: u64, ) -> RpcResult<()>
Report that a shard has completed a tick phase. Read more
Source§async fn route_document(self, _ctx: Context, doc_id: DocumentId) -> ShardId
async fn route_document(self, _ctx: Context, doc_id: DocumentId) -> ShardId
Get the shard responsible for a document. Read more
Source§async fn route_node(self, _ctx: Context, node_id: NodeId) -> ShardId
async fn route_node(self, _ctx: Context, node_id: NodeId) -> ShardId
Get the shard responsible for a node. Read more
Source§async fn get_global_df(
self,
_ctx: Context,
terms: Vec<String>,
) -> RpcResult<HashMap<String, u64>>
async fn get_global_df( self, _ctx: Context, terms: Vec<String>, ) -> RpcResult<HashMap<String, u64>>
Get global document frequencies for TF-IDF. Read more
Source§async fn barrier_ready(
self,
_ctx: Context,
shard_id: ShardId,
phase: TickPhase,
tick: u64,
) -> RpcResult<bool>
async fn barrier_ready( self, _ctx: Context, shard_id: ShardId, phase: TickPhase, tick: u64, ) -> RpcResult<bool>
Signal ready for next phase (barrier). Read more
Source§async fn list_shards(self, _ctx: Context) -> Vec<ShardInfo>
async fn list_shards(self, _ctx: Context) -> Vec<ShardInfo>
Get all registered shards. Read more
Source§async fn start_tick(self, _ctx: Context) -> RpcResult<u64>
async fn start_tick(self, _ctx: Context) -> RpcResult<u64>
Request to start a new tick. Read more
Source§async fn tick_status(self, _ctx: Context) -> RpcResult<TickStatus>
async fn tick_status(self, _ctx: Context) -> RpcResult<TickStatus>
Get the status of the current tick. Read more
Source§fn serve(self) -> ServeCoordinatorService<Self>
fn serve(self) -> ServeCoordinatorService<Self>
Returns a serving function to use with
InFlightRequest::execute.
Auto Trait Implementations§
impl !RefUnwindSafe for CoordinatorServer
impl !UnwindSafe for CoordinatorServer
impl Freeze for CoordinatorServer
impl Send for CoordinatorServer
impl Sync for CoordinatorServer
impl Unpin for CoordinatorServer
impl UnsafeUnpin for CoordinatorServer
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
Mutably borrows from an owned value. Read more