Skip to main content

EngineBuilder

Struct EngineBuilder 

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

Fluent builder for an Engine. Takes plain owned specs instead of a deserialized config schema, so consumers never adopt stream-center’s TOML.

use arcly_stream::prelude::*;

let engine = Engine::builder()
    .max_publishers(1_000)
    .application(AppSpec::new("live").broadcast_capacity(8192))
    .build();
assert_eq!(engine.list_apps().len(), 1);

Implementations§

Source§

impl EngineBuilder

Source

pub fn new() -> Self

A fresh builder with default config, no apps, and permit-all auth.

Source

pub fn max_publishers(self, n: usize) -> Self

Set the hard cap on concurrent publishing streams.

Source

pub fn config(self, config: EngineConfig) -> Self

Replace the whole engine config.

Source

pub fn application(self, app: AppSpec) -> Self

Register an application.

Source

pub fn applications(self, apps: impl IntoIterator<Item = AppSpec>) -> Self

Register many applications at once.

Source

pub fn observer<O: Observer>(self, observer: O) -> Self

Install a telemetry observer. Defaults to NoopObserver if unset.

Source

pub fn observer_arc(self, observer: Arc<dyn Observer>) -> Self

Install a pre-shared observer (when the host already holds an Arc).

Source

pub fn authenticator<A: StreamAuthenticator>(self, auth: A) -> Self

Install a stream authenticator. Defaults to AllowAll if unset.

Source

pub fn authenticator_arc(self, auth: Arc<dyn StreamAuthenticator>) -> Self

Install a pre-shared authenticator (when the host already holds an Arc).

Source

pub fn idle_timeout(self, timeout: Duration) -> Self

Set the idle timeout after which frame-less streams are reaped.

Source

pub fn protocol<P: InboundProtocol>(self, protocol: P) -> Self

Register an inbound protocol worker (RTMP, or any custom InboundProtocol from your own crate). Workers registered here are run by Engine::serve_registered.

let engine = Engine::builder()
    .application(AppSpec::new("live").gop_cache(120))
    .protocol(RtmpHandler::new("0.0.0.0:1935".parse().unwrap()))
    // .protocol(MyCustomProtocol::new())   // your own InboundProtocol
    .build();
engine.serve_registered(CancellationToken::new()).await
Source

pub fn protocol_boxed(self, protocol: Box<dyn InboundProtocol>) -> Self

Register a pre-boxed protocol worker (when the host already holds a Box<dyn InboundProtocol>, e.g. built dynamically from config).

Source

pub fn build(self) -> Arc<Engine>

Build the engine. Any protocol workers registered via protocol are carried into the engine and run by Engine::serve_registered.

Trait Implementations§

Source§

impl Default for EngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more