pub enum FactoryMessage<TKey, TMsg>{
Dispatch(Job<TKey, TMsg>),
Finished(usize, TKey),
DoPings(Instant),
Calculate,
WorkerPong(usize, Duration),
IdentifyStuckWorkers,
GetQueueDepth(RpcReplyPort<usize>),
AdjustWorkerPool(usize),
GetAvailableCapacity(RpcReplyPort<usize>),
GetNumActiveWorkers(RpcReplyPort<usize>),
DrainRequests,
UpdateSettings(UpdateSettingsRequest<TKey, TMsg>),
}Expand description
Messages to a factory.
A special note about factory messages in a distributed context!
Factories only support the command FactoryMessage::Dispatch over a cluster configuration as the rest of the message types are internal and only intended for in-host communication. This means if you’re communicating to a factory you would send only a serialized Job which would automatically be converted to a [FactoryMessage::Dispatch(Job)]
Variants§
Dispatch(Job<TKey, TMsg>)
Dispatch a new message
Finished(usize, TKey)
A job finished
DoPings(Instant)
Send a ping to the workers of the factory along with tracking the factory’s timing itself
Calculate
Calculate factory properties (loadshedding, concurrency, etc)
WorkerPong(usize, Duration)
A reply to a factory ping supplying the worker id and the time of the ping start
IdentifyStuckWorkers
Trigger a scan for stuck worker detection
GetQueueDepth(RpcReplyPort<usize>)
Retrieve the current queue depth (if in a queueing mode)
AdjustWorkerPool(usize)
Resize the worker pool to the requested size
GetAvailableCapacity(RpcReplyPort<usize>)
Retrieve the available capacity of the worker pool + queue
GetNumActiveWorkers(RpcReplyPort<usize>)
Instantaneous measurement of the number of currently processing requests
DrainRequests
Notify the factory that it’s being drained, and to finish jobs currently in the queue, but discard new work, and once drained exit
NOTE: This is different from draining the actor itself, which allows the
pending message queue to flush and then exit. Since the factory
holds an internal queue for jobs, it’s possible that the internal
state still has work to do while the factory’s input queue is drained.
Therefore in order to propertly drain a factory, you should use the
DrainRequests version so the internal pending queue is properly flushed.
UpdateSettings(UpdateSettingsRequest<TKey, TMsg>)
Dynamically update the factory’s settings, for those which don’t require strong-type guarantees. This allows, at runtime, changing the
- Worker Count
- Discard Settings
- Lifecycle Hooks
- Statistics collection
- Capacity controller
- Dead-man’s switch
- Discard handler
Trait Implementations§
Auto Trait Implementations§
impl<TKey, TMsg> Freeze for FactoryMessage<TKey, TMsg>
impl<TKey, TMsg> !RefUnwindSafe for FactoryMessage<TKey, TMsg>
impl<TKey, TMsg> Send for FactoryMessage<TKey, TMsg>
impl<TKey, TMsg> Sync for FactoryMessage<TKey, TMsg>where
TMsg: Sync,
impl<TKey, TMsg> Unpin for FactoryMessage<TKey, TMsg>
impl<TKey, TMsg> UnsafeUnpin for FactoryMessage<TKey, TMsg>where
TKey: UnsafeUnpin,
TMsg: UnsafeUnpin,
impl<TKey, TMsg> !UnwindSafe for FactoryMessage<TKey, TMsg>
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