pub struct Server { /* private fields */ }Expand description
Live server handle: an address bound to an EvalSite, its codec and threading
configuration, lifecycle status, triggers, and optional ServerRuntime.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(
address: ServerAddress,
default_codec: Symbol,
supported_codecs: Vec<Symbol>,
thread: ThreadMode,
isolation: IsolationPolicy,
name: Option<Symbol>,
site: Arc<dyn EvalSite>,
spec: Vec<(Symbol, Expr)>,
) -> Result<Self>
pub fn new( address: ServerAddress, default_codec: Symbol, supported_codecs: Vec<Symbol>, thread: ThreadMode, isolation: IsolationPolicy, name: Option<Symbol>, site: Arc<dyn EvalSite>, spec: Vec<(Symbol, Expr)>, ) -> Result<Self>
Builds a server without an attached runtime.
Sourcepub fn with_runtime(
address: ServerAddress,
default_codec: Symbol,
supported_codecs: Vec<Symbol>,
thread: ThreadMode,
isolation: IsolationPolicy,
name: Option<Symbol>,
site: Arc<dyn EvalSite>,
spec: Vec<(Symbol, Expr)>,
runtime: Option<Arc<ServerRuntime>>,
) -> Result<Self>
pub fn with_runtime( address: ServerAddress, default_codec: Symbol, supported_codecs: Vec<Symbol>, thread: ThreadMode, isolation: IsolationPolicy, name: Option<Symbol>, site: Arc<dyn EvalSite>, spec: Vec<(Symbol, Expr)>, runtime: Option<Arc<ServerRuntime>>, ) -> Result<Self>
Builds a server, optionally attaching a ServerRuntime, after verifying the
address transport is available.
Sourcepub fn address(&self) -> &ServerAddress
pub fn address(&self) -> &ServerAddress
Returns the address the server is bound to.
Sourcepub fn default_codec(&self) -> &Symbol
pub fn default_codec(&self) -> &Symbol
Returns the codec used by default for frames.
Sourcepub fn supported_codecs(&self) -> &[Symbol]
pub fn supported_codecs(&self) -> &[Symbol]
Returns the codecs the server is willing to negotiate.
Sourcepub fn thread(&self) -> &ThreadMode
pub fn thread(&self) -> &ThreadMode
Returns the server’s threading mode.
Sourcepub fn isolation(&self) -> &IsolationPolicy
pub fn isolation(&self) -> &IsolationPolicy
Returns the isolation policy applied to sessions.
Sourcepub fn spec(&self) -> &[(Symbol, Expr)]
pub fn spec(&self) -> &[(Symbol, Expr)]
Returns the configuration spec entries the server was started with.
Sourcepub fn runtime(&self) -> Option<&Arc<ServerRuntime>>
pub fn runtime(&self) -> Option<&Arc<ServerRuntime>>
Returns the attached runtime, if the server is listening.
Sourcepub fn status(&self) -> ServerStatus
pub fn status(&self) -> ServerStatus
Returns the current lifecycle status.
Sourcepub fn set_status(&self, status: ServerStatus)
pub fn set_status(&self, status: ServerStatus)
Sets the lifecycle status.
Sourcepub fn uptime_millis(&self) -> u64
pub fn uptime_millis(&self) -> u64
Returns the elapsed time since the server started, in milliseconds.
Sourcepub fn register_trigger(&self, trigger: Arc<TriggerHandle>) -> Result<()>
pub fn register_trigger(&self, trigger: Arc<TriggerHandle>) -> Result<()>
Registers a trigger handle to be tracked and stopped with the server.
Sourcepub fn stop_triggers(&self) -> Result<()>
pub fn stop_triggers(&self) -> Result<()>
Stops every registered trigger.
Sourcepub fn deliver_trigger_frame(
&self,
cx: &mut Cx,
frame: ServerFrame,
) -> Result<()>
pub fn deliver_trigger_frame( &self, cx: &mut Cx, frame: ServerFrame, ) -> Result<()>
Buffers frame as inbound and delivers it to the eval site, as if fired by a trigger.
Sourcepub fn trigger_snapshots(&self) -> Result<Vec<Arc<TriggerHandle>>>
pub fn trigger_snapshots(&self) -> Result<Vec<Arc<TriggerHandle>>>
Returns a snapshot of the currently registered trigger handles.
Sourcepub fn reflect_value(&self, cx: &mut Cx) -> Result<Value>
pub fn reflect_value(&self, cx: &mut Cx) -> Result<Value>
Returns a table value reflecting the server’s configuration and live state.
Sourcepub fn health_value(&self, cx: &mut Cx) -> Result<Value>
pub fn health_value(&self, cx: &mut Cx) -> Result<Value>
Returns a table value summarizing health: status, uptime, and session and message counts.
Sourcepub fn sessions_value(&self, cx: &mut Cx) -> Result<Value>
pub fn sessions_value(&self, cx: &mut Cx) -> Result<Value>
Returns a list value of the runtime’s sessions, or an empty list if not listening.
Trait Implementations§
Source§impl Object for Server
impl Object for Server
Source§fn display(&self, _cx: &mut Cx) -> Result<String>
fn display(&self, _cx: &mut Cx) -> Result<String>
Source§fn header(&self) -> &ObjectHeader
fn header(&self) -> &ObjectHeader
Source§fn op(&self, _key: &OpKey) -> Option<&dyn Op>
fn op(&self, _key: &OpKey) -> Option<&dyn Op>
key, if any.