pub struct ActorConfig { /* private fields */ }Expand description
Per-actor configuration.
Controls settings that vary between actors, such as the mailbox channel
capacity. Created automatically by Supervisor::add_actor using global
defaults from SupervisorConfig, or customized via ActorBuilder.
§Examples
use maiko::{SupervisorConfig, ActorConfig};
let config = ActorConfig::new(&SupervisorConfig::default())
.with_channel_capacity(512)
.with_max_events_per_tick(64);
assert_eq!(config.channel_capacity(), 512);
assert_eq!(config.max_events_per_tick(), 64);With the builder API (see ActorBuilder):
sup.build_actor("writer", |ctx| Writer::new(ctx))
.channel_capacity(512)
.topics(&[Topic::Data])
.build()?;Implementations§
Source§impl ActorConfig
impl ActorConfig
Sourcepub fn new(global_config: &SupervisorConfig) -> Self
pub fn new(global_config: &SupervisorConfig) -> Self
Create a new config inheriting defaults from the global SupervisorConfig.
Sourcepub fn with_channel_capacity(self, channel_capacity: usize) -> Self
pub fn with_channel_capacity(self, channel_capacity: usize) -> Self
Set the actor’s mailbox channel capacity.
This is the number of events that can be queued for this actor before the broker’s overflow policy takes effect.
Sourcepub fn channel_capacity(&self) -> usize
pub fn channel_capacity(&self) -> usize
Returns the actor’s mailbox channel capacity.
Sourcepub fn with_max_events_per_tick(self, max_events: usize) -> Self
pub fn with_max_events_per_tick(self, max_events: usize) -> Self
Set the maximum number of events processed per tick cycle.
After processing this many events, the actor yields to allow other
tasks to run and to call Actor::step.
Sourcepub fn max_events_per_tick(&self) -> usize
pub fn max_events_per_tick(&self) -> usize
Returns the maximum number of events processed per tick cycle.
Trait Implementations§
Source§impl Clone for ActorConfig
impl Clone for ActorConfig
Source§fn clone(&self) -> ActorConfig
fn clone(&self) -> ActorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more