Skip to main content

ActorConfig

Struct ActorConfig 

Source
pub struct ActorConfig { /* private fields */ }
Expand description

Configuration parameters required to initialize a new actor.

This struct encapsulates the essential settings for creating an actor instance, including its unique identity, its relationship within the actor hierarchy (parent), and its connection to the system message broker.

The actor’s identity is represented by an Ern, which supports hierarchical naming. If a parent actor is specified during configuration, the final Ern of the new actor will be derived by appending its base id to the parent’s Ern.

Implementations§

Source§

impl ActorConfig

Source

pub fn new( id: Ern, parent: Option<ActorHandle>, broker: Option<ActorHandle>, ) -> Result<Self>

Creates a new ActorConfig instance, potentially deriving a hierarchical ID.

This constructor configures a new actor. If a parent handle is provided, the actor’s final id (Ern) is constructed by appending the provided id segment to the parent’s Ern. If no parent is provided, the id is used directly.

§Arguments
  • id - The base identifier (Ern) for the actor. If parent is Some, this acts as the final segment appended to the parent’s ID. If parent is None, this becomes the actor’s root ID.
  • parent - An optional [ParentRef] (handle) to the supervising actor.
  • broker - An optional [BrokerRef] (handle) to the system message broker.
§Returns

Returns a Result containing the configured ActorConfig instance.

§Errors

Returns an error if parsing the parent’s ID string into an Ern fails when constructing a hierarchical ID.

Source

pub const fn with_inbox_capacity(self, capacity: usize) -> Self

Sets a custom inbox capacity for this actor.

This allows overriding the global default inbox capacity on a per-actor basis. High-throughput actors may benefit from larger capacities, while low-throughput actors can use smaller capacities to conserve memory.

§Arguments
  • capacity - The inbox channel capacity for this actor.
§Returns

Returns self for method chaining.

Source

pub const fn with_restart_policy(self, policy: RestartPolicy) -> Self

Sets the restart policy for this actor when supervised.

The restart policy determines how the supervisor handles actor termination:

§Arguments
  • policy - The restart policy to use for this actor.
§Returns

Returns self for method chaining.

Source

pub fn new_with_name(name: impl Into<String>) -> Result<Self>

Creates a new ActorConfig for a top-level actor with a root identifier.

This is a convenience function for creating an ActorConfig for an actor that has no parent (i.e., it’s a root actor in the hierarchy). The provided name is used to create a root Ern.

§Arguments
  • name - A string-like value that will be used as the root name for the actor’s Ern.
§Returns

Returns a Result containing the new ActorConfig instance with no parent or broker.

§Errors

Returns an error if creating the root Ern from the provided name fails (e.g., if the name is invalid according to Ern rules).

Source

pub const fn with_supervision_strategy( self, strategy: SupervisionStrategy, ) -> Self

Sets the supervision strategy for managing child actors.

The supervision strategy determines how the supervisor handles child terminations:

§Arguments
  • strategy - The supervision strategy to use for this actor.
§Returns

Returns self for method chaining.

Source

pub const fn with_restart_limiter(self, config: RestartLimiterConfig) -> Self

Sets the restart limiter configuration for this actor.

The restart limiter controls how frequently an actor can be restarted and applies exponential backoff between restart attempts:

  • Tracks restarts within a sliding time window
  • Limits the maximum number of restarts within that window
  • Applies exponential backoff delays between restarts

When the restart limit is exceeded, the supervisor should escalate the failure to its parent rather than continuing to restart.

§Arguments
§Returns

Returns self for method chaining.

Trait Implementations§

Source§

impl Clone for ActorConfig

Source§

fn clone(&self) -> ActorConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActorConfig

Source§

fn default() -> ActorConfig

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> ActonMessage for T
where T: Any + Send + Sync + Debug + DynClone + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Implementation of as_any for the blanket impl.

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Implementation of as_any_mut for the blanket impl.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more