[][src]Struct capsule::Runtime

pub struct Runtime { /* fields omitted */ }

The Capsule runtime.

The runtime initializes the underlying DPDK environment, and it also manages the task scheduler that executes the packet processing pipelines.

Implementations

impl Runtime[src]

pub fn build(config: RuntimeConfig) -> Fallible<Self>[src]

Builds a runtime from config settings.

pub fn set_on_signal<F>(&mut self, f: F) -> &mut Self where
    F: Fn(UnixSignal) -> bool + 'static, 
[src]

Sets the Unix signal handler.

SIGHUP, SIGINT and SIGTERM are the supported Unix signals. The return of the handler determines whether to terminate the process. true indicates the signal is received and the process should be terminated. false indicates to discard the signal and keep the process running.

Example

Runtime::build(&config)?;
    .set_on_signal(|signal| match signal {
        SIGHUP => {
            reload_config();
            false
        }
        _ => true,
    })
    .execute();

pub fn add_pipeline_to_port<T: Pipeline + 'static, F>(
    &mut self,
    port: &str,
    installer: F
) -> Fallible<&mut Self> where
    F: Fn(PortQueue) -> T + Send + Sync + 'static, 
[src]

Installs a pipeline to a port. The pipeline will run on all the cores assigned to the port.

port is the logical name that identifies the port. The installer is a closure that takes in a PortQueue and returns a Pipeline that will be spawned onto the thread executor.

Example

Runtime::build(config)?
    .add_add_pipeline_to_port("eth1", install)?
    .execute()

pub fn add_kni_rx_pipeline_to_port<T: Pipeline + 'static, F>(
    &mut self,
    port: &str,
    installer: F
) -> Fallible<&mut Self> where
    F: FnOnce(KniRx, PortQueue) -> T + Send + Sync + 'static, 
[src]

Installs a pipeline to a KNI enabled port to receive packets coming from the kernel. This pipeline will run on a randomly select core that's assigned to the port.

Remarks

This function has be to invoked once per port. Otherwise the packets coming from the kernel will be silently dropped. For the most common use case where the application only needs simple packet forwarding, use batch::splice to join the kernel's RX with the port's TX.

Example

Runtime::build(config)?
    .add_add_pipeline_to_port("kni0", install)?
    .add_kni_rx_pipeline_to_port("kni0", batch::splice)?
    .execute()

pub fn add_pipeline_to_core<T: Pipeline + 'static, F>(
    &mut self,
    core: usize,
    installer: F
) -> Fallible<&mut Self> where
    F: FnOnce(HashMap<String, PortQueue>) -> T + Send + Sync + 'static, 
[src]

Installs a pipeline to a core. All the ports the core is assigned to will be available to the pipeline.

core is the logical id that identifies the core. The installer is a closure that takes in a hashmap of PortQueues and returns a Pipeline that will be spawned onto the thread executor of the core.

Example

Runtime::build(config)?
    .add_pipeline_to_core(1, install)?
    .execute()

pub fn add_periodic_pipeline_to_core<T: Pipeline + 'static, F>(
    &mut self,
    core: usize,
    installer: F,
    dur: Duration
) -> Fallible<&mut Self> where
    F: FnOnce(HashMap<String, PortQueue>) -> T + Send + Sync + 'static, 
[src]

Installs a periodic pipeline to a core.

core is the logical id that identifies the core. The installer is a closure that takes in a hashmap of PortQueues and returns a Pipeline that will be run periodically every dur interval.

Remarks

All the ports the core is assigned to will be available to this pipeline. However they should only be used to transmit packets. This variant is for pipelines that generate new packets periodically. A new packet batch can be created with batch::poll_fn and ingested into the pipeline.

Example

Runtime::build(config)?
    .add_periodic_pipeline_to_core(1, install, Duration::from_millis(10))?
    .execute()

pub fn add_periodic_task_to_core<F>(
    &mut self,
    core: usize,
    task: F,
    dur: Duration
) -> Fallible<&mut Self> where
    F: Fn() + Send + Sync + 'static, 
[src]

Installs a periodic task to a core.

core is the logical id that identifies the core. task is the closure to execute. The task will rerun every dur interval.

Example

Runtime::build(config)?
    .add_periodic_task_to_core(0, print_stats, Duration::from_secs(1))?
    .execute()

pub fn execute(&mut self) -> Fallible<()>[src]

Executes the pipeline(s) until a stop signal is received.

Trait Implementations

impl<'a> Debug for Runtime[src]

impl Drop for Runtime[src]

Auto Trait Implementations

impl !RefUnwindSafe for Runtime

impl !Send for Runtime

impl !Sync for Runtime

impl Unpin for Runtime

impl !UnwindSafe for Runtime

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,