pub struct ThreadedEngine { /* private fields */ }
Expand description
Thread-safe wrapper around Engine that enables vertical scaling through thread pools
Implementations§
Source§impl ThreadedEngine
impl ThreadedEngine
Sourcepub fn new(
workflows: Vec<Workflow>,
custom_functions: Option<HashMap<String, Box<dyn FunctionHandler + Send + Sync>>>,
retry_config: Option<RetryConfig>,
thread_count: usize,
) -> Self
pub fn new( workflows: Vec<Workflow>, custom_functions: Option<HashMap<String, Box<dyn FunctionHandler + Send + Sync>>>, retry_config: Option<RetryConfig>, thread_count: usize, ) -> Self
Creates a new ThreadedEngine with configurable thread pool size
§Arguments
workflows
- The workflows to use for processing messagescustom_functions
- Optional custom function handlersretry_config
- Optional retry configurationthread_count
- Number of worker threads to spawn
Sourcepub async fn process_message(&self, message: Message) -> Result<Message>
pub async fn process_message(&self, message: Message) -> Result<Message>
Process a message asynchronously using the thread pool
Sourcepub fn process_message_sync(&self, message: Message) -> Result<Message>
pub fn process_message_sync(&self, message: Message) -> Result<Message>
Process a message synchronously (blocks until complete)
Sourcepub fn wait_for_shutdown(self)
pub fn wait_for_shutdown(self)
Waits for all workers to finish current work and terminate
Sourcepub fn shutdown_with_timeout(self, timeout: Duration)
pub fn shutdown_with_timeout(self, timeout: Duration)
Shutdown with timeout
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Health check for worker threads
Sourcepub fn thread_count(&self) -> usize
pub fn thread_count(&self) -> usize
Get the number of worker threads
Trait Implementations§
Source§impl Clone for ThreadedEngine
impl Clone for ThreadedEngine
Auto Trait Implementations§
impl !Freeze for ThreadedEngine
impl !RefUnwindSafe for ThreadedEngine
impl Send for ThreadedEngine
impl Sync for ThreadedEngine
impl Unpin for ThreadedEngine
impl !UnwindSafe for ThreadedEngine
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
Mutably borrows from an owned value. Read more