Skip to main content

FactoryArguments

Struct FactoryArguments 

Source
pub struct FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TKey: JobKey, TMsg: Message, TWorkerStart: Message, TWorker: Actor<Msg = WorkerMessage<TKey, TMsg>, Arguments = WorkerStartContext<TKey, TMsg, TWorkerStart>>, TRouter: Router<TKey, TMsg>, TQueue: Queue<TKey, TMsg>,
{ pub worker_builder: Box<dyn WorkerBuilder<TWorker, TWorkerStart>>, pub num_initial_workers: usize, pub router: TRouter, pub queue: TQueue, pub discard_handler: Option<Arc<dyn DiscardHandler<TKey, TMsg>>>, pub discard_settings: DiscardSettings, pub dead_mans_switch: Option<DeadMansSwitchConfiguration>, pub capacity_controller: Option<Box<dyn WorkerCapacityController>>, pub lifecycle_hooks: Option<Box<dyn FactoryLifecycleHooks<TKey, TMsg>>>, pub stats: Option<Arc<dyn FactoryStatsLayer>>, }
Expand description

Arguments for configuring and starting a Factory actor instance.

Fields§

§worker_builder: Box<dyn WorkerBuilder<TWorker, TWorkerStart>>

The factory is responsible for spawning workers and re-spawning workers under failure scenarios. This means that it needs to understand how to build workers. The WorkerBuilder trait is used by the factory to construct new workers when needed.

§num_initial_workers: usize

Number of (initial) workers in the factory

Default = 1 worker

§router: TRouter

Message routing handler

§queue: TQueue

Message queue implementation for the factory

§discard_handler: Option<Arc<dyn DiscardHandler<TKey, TMsg>>>

Discard callback when a job is discarded.

Default is None

§discard_settings: DiscardSettings

Maximum queue length. Any job arriving when the queue is at its max length will cause a job at the head or tail of the queue to be dropped (which is controlled by discard_mode).

  • For factories using routing protocols like routing::QueuerRouting, routing::StickyQueuerRouting routing, these are applied to the factory’s internal queue.
  • For all other routing non-factory-queueing protocols, this applies to the worker’s message queue

Default is DiscardSettings::None

§dead_mans_switch: Option<DeadMansSwitchConfiguration>

Controls the “dead man’s” switching logic on the factory. Periodically the factory will scan for stuck workers. If detected, the worker information will be logged along with the current job key information. Optionally the worker can be killed and replaced by the factory

Default is None

§capacity_controller: Option<Box<dyn WorkerCapacityController>>

Controls the parallel capacity of the worker pool by dynamically growing/shrinking the pool

Default is None

§lifecycle_hooks: Option<Box<dyn FactoryLifecycleHooks<TKey, TMsg>>>

Lifecycle hooks provide access to points in the factory’s lifecycle for shutdown/startup/draining where user-defined logic can execute (and block factory lifecycle at critical points). For example, this means the factory won’t start accepting requests until the complete startup routine is completed.

Default is None

§stats: Option<Arc<dyn FactoryStatsLayer>>

Defines the statistics collection layer for the factory. Useful for tracking factory properties.

Default is None

Implementations§

Source§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TKey: JobKey, TMsg: Message, TWorkerStart: Message, TWorker: Actor<Msg = WorkerMessage<TKey, TMsg>, Arguments = WorkerStartContext<TKey, TMsg, TWorkerStart>>, TRouter: Router<TKey, TMsg>, TQueue: Queue<TKey, TMsg>,

Source

pub fn builder() -> FactoryArgumentsBuilder<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>

Create an instance of FactoryArguments using the builder syntax

Trait Implementations§

Source§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Debug for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TKey: JobKey, TMsg: Message, TWorkerStart: Message, TWorker: Actor<Msg = WorkerMessage<TKey, TMsg>, Arguments = WorkerStartContext<TKey, TMsg, TWorkerStart>>, TRouter: Router<TKey, TMsg>, TQueue: Queue<TKey, TMsg>,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Freeze for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TRouter: Freeze, TQueue: Freeze,

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> !RefUnwindSafe for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Send for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Sync for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TRouter: Sync, TQueue: Sync,

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Unpin for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TRouter: Unpin, TQueue: Unpin,

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> UnsafeUnpin for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
where TRouter: UnsafeUnpin, TQueue: UnsafeUnpin,

§

impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> !UnwindSafe for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Message for T
where T: Any + Send + 'static,

Source§

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type
Source§

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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
Source§

impl<T> State for T
where T: Any + Send + 'static,