Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub channel_size: usize,
    pub max_events_per_tick: usize,
    pub maintenance_interval: Duration,
    pub monitoring_channel_size: usize,
}
Expand description

Runtime configuration for the supervisor and actors.

Controls channel buffer sizes and event batching behavior. Use the builder pattern to customize, or use Default for sensible defaults.

§Examples

use maiko::Config;

let config = Config::default()
    .with_channel_size(256)            // Larger buffers for high throughput
    .with_max_events_per_tick(20);     // Process more events per cycle

Fields§

§channel_size: usize

Size of the channel buffer for each actor (and the broker). Determines how many events can be queued before backpressure applies. Default: 128

§max_events_per_tick: usize

Maximum number of events an actor will process in a single tick cycle before yielding control back to the scheduler. Lower values improve fairness, higher values improve throughput. Default: 10

§maintenance_interval: Duration§monitoring_channel_size: usize

Implementations§

Source§

impl Config

Source

pub fn with_channel_size(self, size: usize) -> Self

Set the channel buffer size for actors and the broker.

Larger buffers allow more queued events but use more memory. When the buffer is full, senders will block (backpressure).

Source

pub fn with_max_events_per_tick(self, limit: usize) -> Self

Set the maximum number of events processed per tick cycle.

This controls batching behavior in the actor event loop. After processing this many events, the actor yields to allow other tasks to run and to call Actor::step.

Trade-offs:

  • Lower values (1-5): Better fairness, more responsive step(), higher overhead
  • Higher values (50-100): Better throughput, potential starvation of step()
Source

pub fn with_maintenance_interval(self, interval: Duration) -> Self

Set the maintenance interval for the broker.

This controls how often the broker cleans up expired subscribers.

Source

pub fn with_monitoring_channel_size(self, size: usize) -> Self

Trait Implementations§

Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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.