RuntimeHandle

Struct RuntimeHandle 

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

A cheap clone of the runtime, safe to hand to flavors and connection tasks.

Implementations§

Source§

impl RuntimeHandle

Source

pub fn ids(&self) -> &SharedIds

The runtime-wide identifier allocator.

Public because the gateway needs a connection’s session before any shard has rendered it: ServerSync carries it, and the handshake happens before the first turn.

Source

pub fn peers(&self) -> &Arc<Peers>

Source

pub fn next_connection(&self) -> ConnectionId

Reserve the next connection identifier. Never reused.

Source

pub fn session_for( &self, connection: ConnectionId, ) -> Result<SessionId, Exhausted>

The session a connection will be rendered under, allocated now so the handshake can announce it.

§Errors

Once the session space is spent.

Source

pub fn create_shard<L: ShardLogic>( &self, build: impl FnOnce(ShardHandle) -> L, ) -> ShardHandle

Create a shard and start its task.

The chicken and the egg - a flavor usually wants to wake the shard that owns it - are resolved by a closure: the handle exists before the logic that will hold it.

Source

pub fn destroy_shard(&self, shard: ShardId, reason: &str)

Destroy a shard.

The guide leaves the policy for its connections open (17.4). The safe default, and what this does, is to close them: a connection left pointing at a shard that no longer renders would hold a view nothing can ever update. A flavor that wants a fallback shard migrates them first and destroys afterwards.

Source

pub fn move_connection(&self, connection: ConnectionId, to: ShardId)

Move a connection to another shard.

Not a disconnect followed by a connect. The source shard hands over the view the client still holds, and the destination plans one transition from it onto its own tree, which is the same slow path a scope change takes: whatever the two trees have in common does not flicker.

Doing it the other way round is not merely wasteful, it disconnects the official client. It keeps itself in its own model after a UserRemove naming its own session, so the ChannelRemove that follows looks to it like the server removing an occupied channel, which it treats as a protocol violation.

REF: references/mumble/src/mumble/Messages.cpp : msgUserRemove calls removeUser only if (pDst != pSelf); msgChannelRemove logs “Protocol violation. Server sent remove for occupied channel.” and disconnects when UserModel::removeChannel(c, true) refuses.

Source

pub fn attach( &self, peer: &Arc<Peer>, shard: ShardId, ) -> Result<Receiver<()>, AttachError>

Attach a connection that has just been routed.

Returns the receiver that fires once the shard has accepted the connection’s first transition, which is what the handshake waits on before sending ServerSync.

§Errors

When the shard does not exist, or its mailbox is full.

Source

pub fn detach(&self, connection: ConnectionId, shard: ShardId, reason: &str)

Tell a connection’s shard that it is gone.

Source

pub fn send( &self, shard: ShardId, command: ShardCommand, ) -> Result<(), AttachError>

Forward a command to a shard.

§Errors

When the shard does not exist or its mailbox is full.

Source

pub fn status(&self) -> Vec<ShardStatus>

What an operator would want on a status page.

Source

pub fn shard_handle(&self, shard: ShardId) -> Option<ShardHandle>

Trait Implementations§

Source§

impl Clone for RuntimeHandle

Source§

fn clone(&self) -> RuntimeHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RuntimeHandle

Source§

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

Formats the value using the given formatter. Read more

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, 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
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.