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: usizeNumber of (initial) workers in the factory
Default = 1 worker
router: TRouterMessage routing handler
queue: TQueueMessage 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: DiscardSettingsMaximum 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>,
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>,
Sourcepub fn builder() -> FactoryArgumentsBuilder<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
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>,
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>,
Auto Trait Implementations§
impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Freeze for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
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>
impl<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue> Unpin for FactoryArguments<TKey, TMsg, TWorkerStart, TWorker, TRouter, TQueue>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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