pub struct ActorBuilder<'a, E: Event, T: Topic<E>, A: Actor<Event = E>> { /* private fields */ }Expand description
Builder for registering an actor with custom configuration.
Returned by Supervisor::build_actor. Use this when you need to override
per-actor settings such as channel capacity or when you want to separate
actor construction from topic subscription.
Defaults to no topic subscriptions and channel capacity inherited from the
global SupervisorConfig.
§Examples
// Custom channel capacity for a slow consumer
sup.build_actor("writer", |ctx| Writer::new(ctx))
.topics(&[Topic::Data])
.channel_capacity(512)
.build()?;
// Replace the entire actor config
sup.build_actor("fast", |ctx| Fast::new(ctx))
.topics(Subscribe::all())
.config(my_config)
.build()?;Implementations§
Source§impl<'a, E: Event, T: Topic<E>, A: Actor<Event = E>> ActorBuilder<'a, E, T, A>
impl<'a, E: Event, T: Topic<E>, A: Actor<Event = E>> ActorBuilder<'a, E, T, A>
Sourcepub fn topics<S>(self, topics: S) -> Self
pub fn topics<S>(self, topics: S) -> Self
Set the topics this actor subscribes to.
Accepts anything that converts to Subscribe: a topic slice,
Subscribe::all(), or Subscribe::none().
Sourcepub fn config<C>(self, config: C) -> Selfwhere
C: Into<ActorConfig>,
pub fn config<C>(self, config: C) -> Selfwhere
C: Into<ActorConfig>,
Replace the entire ActorConfig for this actor.
Sourcepub fn with_config<F>(self, f: F) -> Self
pub fn with_config<F>(self, f: F) -> Self
Transform the current ActorConfig with a closure.
Unlike config() which replaces the entire config,
this preserves inherited defaults and lets you tweak individual fields.
sup.build_actor("consumer", |ctx| Consumer::new(ctx))
.topics(&[Topic::Data])
.channel_capacity(256)
.with_config(|c| c.with_max_events_per_tick(64))
.build()?;Sourcepub fn channel_capacity(self, capacity: usize) -> Self
pub fn channel_capacity(self, capacity: usize) -> Self
Set the actor’s mailbox channel capacity.
Shorthand for modifying the channel capacity without replacing the
full config. See ActorConfig::with_channel_capacity.