Skip to main content

ServerRuntime

Struct ServerRuntime 

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

Server-side runtime: owns the transport, tracks live sessions and worker threads, and records connection and message counters.

Implementations§

Source§

impl ServerRuntime

Source

pub fn new( transport: Arc<dyn ServerTransport>, cx: Cx, thread_mode: ThreadMode, max_inflight: usize, ) -> Self

Creates a runtime with the default session isolation policy.

Source

pub fn new_with_isolation( transport: Arc<dyn ServerTransport>, cx: Cx, thread_mode: ThreadMode, max_inflight: usize, session_isolation: IsolationPolicy, ) -> Self

Creates a runtime with an explicit session isolation policy applied to new sessions.

Source

pub fn transport(&self) -> &Arc<dyn ServerTransport>

Returns the transport this runtime accepts connections on.

Source

pub fn thread_mode(&self) -> &ThreadMode

Returns the threading mode used to service connections.

Source

pub fn session_count(&self) -> usize

Returns the number of currently open sessions.

Source

pub fn sessions(&self) -> Result<Vec<Session>>

Returns a snapshot of all open sessions.

Source

pub fn begin_stop(&self)

Signals that the runtime should stop accepting and servicing connections.

Source

pub fn is_stopping(&self) -> bool

Returns whether a stop has been requested.

Source

pub fn open_session( &self, negotiated_codec: Symbol, isolation: IsolationPolicy, ) -> Result<u64>

Opens a new session with the given codec and isolation policy, returning its id.

Source

pub fn update_session_codec( &self, session_id: u64, negotiated_codec: Symbol, ) -> Result<()>

Updates the negotiated codec for an existing session; a no-op if the session is gone.

Source

pub fn close_session(&self, session_id: u64) -> Result<()>

Removes the session with session_id from the runtime.

Source

pub fn clear_sessions(&self) -> Result<()>

Removes all sessions from the runtime.

Source

pub fn connection_count(&self) -> u64

Returns the total number of connections opened over the runtime’s lifetime.

Source

pub fn messages_sent(&self) -> u64

Returns the total number of messages sent.

Source

pub fn messages_received(&self) -> u64

Returns the total number of messages received.

Source

pub fn max_inflight(&self) -> usize

Returns the maximum number of in-flight requests permitted.

Source

pub fn session_isolation(&self) -> &IsolationPolicy

Returns the isolation policy applied to new sessions.

Source

pub fn note_message_sent(&self)

Increments the sent-message counter.

Source

pub fn note_message_received(&self)

Increments the received-message counter.

Source

pub fn with_cx<T>(&self, f: impl FnOnce(&mut Cx) -> Result<T>) -> Result<T>

Runs f with exclusive access to the runtime’s shared evaluation context.

Source

pub fn set_accept_thread(&self, handle: JoinHandle<()>) -> Result<()>

Stores the join handle for the connection-accept thread.

Source

pub fn join_accept_thread(&self) -> Result<()>

Joins the accept thread if one is registered.

Source

pub fn register_worker_thread(&self, handle: JoinHandle<()>) -> Result<()>

Records a worker thread’s join handle for later cleanup.

Source

pub fn join_worker_threads(&self) -> Result<()>

Joins and drains all registered worker threads.

Source

pub fn accept_timeout( &self, timeout: Duration, ) -> Result<Option<Box<dyn ConnectionTransport>>>

Waits up to timeout for an incoming connection, returning its transport if one arrives.

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.

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