Skip to main content

RoomManager

Struct RoomManager 

Source
pub struct RoomManager {
    directory: RwLock<RoomDirectory>,
    factory: RoomFactory,
    reservation_ttl: Duration,
}
Expand description

Coordinates current room admission and lifecycle.

Fields§

§directory: RwLock<RoomDirectory>§factory: RoomFactory§reservation_ttl: Duration

Implementations§

Source§

impl RoomManager

Source

pub fn new( runtime_policy: RoomRuntimePolicy, metrics: Arc<RuntimeMetrics>, reservation_ttl: Duration, ) -> Self

builds a room manager with an empty directory

Source

pub async fn serve_room( &self, issuer: &str, key: &str, config: &RoomConfig, remote_address: Option<&str>, ) -> Result<Arc<Room>, RoomManagerServeError>

Returns the current room for issuer or publishes a new reservation.

The first reservation fixes key, config and remote_address. Matching requests return the same room and renew an outstanding reservation without rearming one retired by a successful join.

§Errors

Returns RoomManagerServeError::ConflictingReservation when the current room has a different key or config.

Source

pub async fn get_by_uuid(&self, uuid: &str) -> Option<Arc<Room>>

returns the current room for a public room uuid

Source

pub async fn stats_snapshots( &self, media_transport: &MediaTransport, ) -> Vec<RuntimeRoomStatsSnapshot>

builds /v1/stats rows from one directory snapshot

the directory lock is released before transport stats are read, so the returned rows are best-effort runtime observations rather than a global transaction across room and media state

Source

pub async fn directory_snapshots(&self) -> Vec<RuntimeRoomDirectorySnapshot>

returns current directory rows for room diagnostics

Source

pub async fn room_gauges(&self) -> RoomGaugeValues

Returns counts from rooms in one directory snapshot.

Room states are read sequentially after the directory lock is released. Removed rooms may contribute once. New rooms appear on the next call.

Source

pub async fn directory_snapshot( &self, room_id: &str, ) -> Option<RuntimeRoomDirectorySnapshot>

returns one current directory row for room diagnostics

Source

pub async fn sync_source_packet_selection_policies_for_runtime_ids( &self, room_instance_ids: &BTreeSet<RoomInstanceId>, media_transport: &MediaTransport, )

recalculates packet-selection policy for rooms dirtied by media activity

empty input is a no-op. rooms that left the current directory before the drain are skipped. committed route work is executed after each policy plan so transport routing and accepted selector state stay in sync

Source

pub async fn join_user( &self, room_id: &str, request: JoinUserRequest, media_transport: &MediaTransport, ) -> Result<RoomUserAdmission, RoomManagerJoinError>

Admits one WebSocket connection into a current room.

Returns after join-side room effects complete.

§Errors

Returns RoomManagerJoinError::MissingRoom when room_id is not current. Returns RoomManagerJoinError::RoomFull when a new user exceeds room capacity. Returns RoomManagerJoinError::RouterState when router placement cannot commit.

§Panics

Panics when existing relay state refers to an uncommitted source placement.

Source

pub async fn close_session( &self, room_id: &str, user_id: &UserId, connection_id: ConnectionId, media_transport: &MediaTransport, ) -> bool

closes one room connection and then re-checks empty-room removal

returns false when the room is missing or the connection was not removed by this call. the empty current room can still be removed after stale or already-completed teardown

Source

pub async fn disconnect_users( &self, room_id: &str, user_ids: &[UserId], media_transport: &MediaTransport, )

disconnects selected users from a current room and removes it if empty

missing rooms are ignored because the caller’s disconnect intent is already satisfied

Source

pub async fn check_expired_room_reservations(&self)

Claims and removes expired reservations with no active room mutations.

Source

async fn run_current_room_mutation<T, F, Fut>( &self, room_id: &str, action: F, remove_if_empty: bool, ) -> Option<(Arc<Room>, T)>
where F: FnOnce(Arc<Room>) -> Fut, Fut: Future<Output = T>,

Source

async fn finish_session_mutation( &self, room_id: &str, mutation: CurrentRoomMutation, remove_if_empty: bool, )

Source

async fn begin_current_room_mutation( &self, room_id: &str, ) -> Option<CurrentRoomMutation>

accepts work only against the directory-current room row

the returned mutation holds no directory lock. if the row is replaced between snapshot and current check, the lease is cancelled and the caller sees None

Source

async fn entry(&self, room_id: &str) -> Option<RoomDirectoryEntry>

Source

async fn directory_entries(&self) -> Vec<RoomDirectoryEntry>

Source

async fn directory_entries_for_instance_ids( &self, room_instance_ids: &BTreeSet<RoomInstanceId>, ) -> Vec<Arc<Room>>

Source

async fn entry_stats_snapshot( &self, entry: RoomDirectoryEntry, media_transport: &MediaTransport, ) -> RuntimeRoomStatsSnapshot

Source

async fn is_current_entry(&self, room_id: &str, room: &Arc<Room>) -> bool

Trait Implementations§

Source§

impl Debug for RoomManager

Source§

fn fmt(&self, f: &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

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

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

fn with_current_context(self) -> WithContext<Self>

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> CryptoSafe for T
where T: Send + Sync + Debug,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,