Skip to main content

ShardServer

Struct ShardServer 

Source
pub struct ShardServer { /* private fields */ }
Expand description

Server implementation for a shard.

ShardServer wraps a ShardedColony and implements the ShardService trait, allowing remote clients to interact with the shard via tarpc RPC.

§Thread Safety

The server uses Arc<RwLock<ShardedColony>> to allow safe concurrent access from multiple RPC handler tasks.

§Example

use phago_distributed::rpc::server::ShardServer;
use phago_distributed::shard::ShardedColony;

let shard = Arc::new(RwLock::new(ShardedColony::new(...)));
let server = ShardServer::new(shard);
server.serve("127.0.0.1:8080".parse().unwrap()).await?;

Implementations§

Source§

impl ShardServer

Source

pub fn new(shard: Arc<RwLock<ShardedColony>>) -> Self

Create a new shard server.

§Arguments
  • shard - The sharded colony to serve
Source

pub async fn start(self, addr: SocketAddr) -> Result<(), Error>

Start serving on the given address.

This method listens for incoming connections and spawns a task for each client to handle their requests concurrently.

§Arguments
  • addr - The socket address to bind to
§Errors

Returns an error if the server fails to bind to the address.

Trait Implementations§

Source§

impl Clone for ShardServer

Source§

fn clone(&self) -> ShardServer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ShardService for ShardServer

Source§

async fn ingest_document( self, _ctx: Context, doc: Document, ) -> RpcResult<DocumentId>

Ingest a document into this shard. Read more
Source§

async fn tick_phase( self, _ctx: Context, phase: TickPhase, tick: u64, ) -> RpcResult<PhaseResult>

Execute a tick phase on this shard. Read more
Source§

async fn local_query( self, _ctx: Context, req: LocalQueryRequest, ) -> RpcResult<LocalQueryResult>

Execute a local query (part of distributed query). Read more
Source§

async fn get_term_frequencies( self, _ctx: Context, terms: Vec<String>, ) -> RpcResult<HashMap<String, u64>>

Get term frequencies for global DF computation. Read more
Source§

async fn get_node( self, _ctx: Context, id: NodeId, ) -> RpcResult<Option<NodeData>>

Fetch a node’s full data (for ghost node resolution). Read more
Source§

async fn health_check(self, _ctx: Context) -> RpcResult<ShardHealth>

Health check. Read more
Source§

async fn resolve_ghost_nodes( self, _ctx: Context, node_ids: Vec<NodeId>, ) -> RpcResult<Vec<GhostNode>>

Resolve cross-shard edges by fetching ghost node data. Read more
Source§

async fn get_neighbors( self, _ctx: Context, node_id: NodeId, ) -> RpcResult<Vec<NodeId>>

Get the list of nodes connected to a given node. Read more
Source§

async fn receive_signals( self, _ctx: Context, signals: Vec<CrossShardSignal>, ) -> RpcResult<()>

Receive cross-shard signals during the Exchange phase. Read more
Source§

fn serve(self) -> ServeShardService<Self>

Returns a serving function to use with InFlightRequest::execute.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more