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
impl RuntimeHandle
Sourcepub fn ids(&self) -> &SharedIds
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.
pub fn peers(&self) -> &Arc<Peers>
Sourcepub fn next_connection(&self) -> ConnectionId
pub fn next_connection(&self) -> ConnectionId
Reserve the next connection identifier. Never reused.
Sourcepub fn session_for(
&self,
connection: ConnectionId,
) -> Result<SessionId, Exhausted>
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.
Sourcepub fn create_shard<L: ShardLogic>(
&self,
build: impl FnOnce(ShardHandle) -> L,
) -> ShardHandle
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.
Sourcepub fn destroy_shard(&self, shard: ShardId, reason: &str)
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.
Sourcepub fn move_connection(&self, connection: ConnectionId, to: ShardId)
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.
Sourcepub fn attach(
&self,
peer: &Arc<Peer>,
shard: ShardId,
) -> Result<Receiver<()>, AttachError>
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.
Sourcepub fn detach(&self, connection: ConnectionId, shard: ShardId, reason: &str)
pub fn detach(&self, connection: ConnectionId, shard: ShardId, reason: &str)
Tell a connection’s shard that it is gone.
Sourcepub fn send(
&self,
shard: ShardId,
command: ShardCommand,
) -> Result<(), AttachError>
pub fn send( &self, shard: ShardId, command: ShardCommand, ) -> Result<(), AttachError>
Sourcepub fn status(&self) -> Vec<ShardStatus>
pub fn status(&self) -> Vec<ShardStatus>
What an operator would want on a status page.
pub fn shard_handle(&self, shard: ShardId) -> Option<ShardHandle>
Trait Implementations§
Source§impl Clone for RuntimeHandle
impl Clone for RuntimeHandle
Source§fn clone(&self) -> RuntimeHandle
fn clone(&self) -> RuntimeHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more