Trait casper_node::reactor::Reactor[][src]

pub trait Reactor: Sized {
    type Event: ReactorEvent + Display;
    type Config;
    type Error: Send + 'static;
    fn dispatch_event(
        &mut self,
        effect_builder: EffectBuilder<Self::Event>,
        rng: &mut NodeRng,
        event: Self::Event
    ) -> Effects<Self::Event>;
fn new(
        cfg: Self::Config,
        registry: &Registry,
        event_queue: EventQueueHandle<Self::Event>,
        rng: &mut NodeRng
    ) -> Result<(Self, Effects<Self::Event>), Self::Error>;
fn maybe_exit(&self) -> Option<ReactorExit>; fn update_metrics(
        &mut self,
        _event_queue_handle: EventQueueHandle<Self::Event>
    ) { ... } }
Expand description

Reactor core.

Any reactor should implement this trait and be executed by the reactor::run function.

Associated Types

Event type associated with reactor.

Defines what kind of event the reactor processes.

A configuration for the reactor

The error type returned by the reactor.

Required methods

Dispatches an event on the reactor.

This function is typically only called by the reactor itself to dispatch an event. It is safe to call regardless, but will cause the event to skip the queue and things like accounting.

Creates a new instance of the reactor.

This method creates the full state, which consists of all components, and returns a reactor instance along with the effects that the components generated upon instantiation.

If any instantiation fails, an error is returned.

If Some, indicates that the reactor has completed all its work and should no longer dispatch events. The running process may stop or may keep running with a new reactor.

Provided methods

Instructs the reactor to update performance metrics, if any.

Implementors