Struct UPC

pub struct UPC<E: Debug> { /* private fields */ }
Expand description

Universal Procedure Call (UPC) is a modernized and generalized form of RPC.

It hosts regular RPCs in a more peer-to-peer manner (each node may have either/both “caller” and “callee” roles, instead distinct “server/clients”) and truly achieves what a “remote prodecure” should have been like: direct passing of (typed) local objects as the input/output of a call and eliminating the difference between an actual remote call and a local call. It also allows a multicast-style RPC (https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/) which is at the core of map-reduce/consensus/MPC implementations where the same request is sent to a selected group of different nodes and a threshold of the results are expected to calculate the final result.

In UPC, each callable site is called an endpoint whereas one endpoint has potentially multiple callee/callers. The endpoint is identified by a customizable identifier I which implements basic methods to convert from/to 32-byte arrays (a typical identifier can be a 256-bit hash or crypto address). One needs to (optionally) register a Caller/Callee implementation which defines the computation triggered by a UPC call. For each endpoint, it can define a set of methods for UPC. At any endpoint, each UPC call is uniquely identified by method and id. The id is used to separate simultaneous calls and may be reused. Additionally, each call requires a number that gets passed into Caller to capture the common abstract concept that the caller implementation may have its internal state. With Requester, one can initiate a UPC request.

Implementations§

§

impl<E: Send + Debug + 'static> UPC<E>

pub fn new(network: Hub, pool_size: usize) -> Self

pub async fn register_callee<C: Callee<Error = E> + 'static>( &self, lyquid: &LyquidID, callee: C, ) -> Result<(), Error<E>>

pub async fn register_caller<C: Caller<Error = E> + 'static>( &self, lyquid: &LyquidID, caller: C, ) -> Result<(), Error<E>>

pub fn deregister_caller(&self, id: &LyquidID)

pub fn deregister_callee(&self, id: &LyquidID)

pub async fn add_remote( &mut self, node: NodeID, address: Option<String>, ) -> Result<(), Error<E>>

pub async fn remove_remote(&mut self, remote: NodeID) -> Result<(), Error<E>>

pub async fn start(&self) -> Result<(), Error<E>>

pub fn requester(&self) -> Requester<E>

pub fn node_id(&self) -> &NodeID

Trait Implementations§

§

impl<E: Debug> Debug for UPC<E>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> !Freeze for UPC<E>

§

impl<E> !RefUnwindSafe for UPC<E>

§

impl<E> Send for UPC<E>

§

impl<E> Sync for UPC<E>

§

impl<E> Unpin for UPC<E>

§

impl<E> !UnwindSafe for UPC<E>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<'de, F, T> Deserialize<'de, As<F>> for T
where F: BareFormula + ?Sized, T: Deserialize<'de, F>,

§

fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>

Deserializes value provided deserializer. Returns deserialized value and the number of bytes consumed from the and of input. Read more
§

fn deserialize_in_place( &mut self, deserializer: Deserializer<'de>, ) -> Result<(), DeserializeError>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. Read more
§

impl<'de, F, T> Deserialize<'de, Ref<F>> for T
where F: BareFormula + ?Sized, T: Deserialize<'de, F> + ?Sized,

§

fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>

Deserializes value provided deserializer. Returns deserialized value and the number of bytes consumed from the and of input. Read more
§

fn deserialize_in_place( &mut self, de: Deserializer<'de>, ) -> Result<(), DeserializeError>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
§

impl<F, T> Serialize<As<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. Read more
§

impl<F, T> Serialize<Ref<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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