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 cycleFields§
§channel_size: usizeSize 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: usizeMaximum 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: usizeImplementations§
Source§impl Config
impl Config
Sourcepub fn with_channel_size(self, size: usize) -> Self
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).
Sourcepub fn with_max_events_per_tick(self, limit: usize) -> Self
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()
Sourcepub fn with_maintenance_interval(self, interval: Duration) -> Self
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.