pub struct WorkerPool { /* private fields */ }Expand description
In-process worker pool with bounded queues and health-aware routing.
Implementations§
Source§impl WorkerPool
impl WorkerPool
Sourcepub fn new_inprocess(
handlers: Vec<Arc<dyn WorkerHandler>>,
options: WorkerPoolOptions,
hooks: Option<Arc<dyn CircuitBreakerHooks>>,
) -> Result<Self, WorkerPoolError>
pub fn new_inprocess( handlers: Vec<Arc<dyn WorkerHandler>>, options: WorkerPoolOptions, hooks: Option<Arc<dyn CircuitBreakerHooks>>, ) -> Result<Self, WorkerPoolError>
Creates and starts an in-process worker pool.
Sourcepub async fn submit(
&self,
request: WorkerRequest,
) -> Result<WorkerResponse, WorkerPoolError>
pub async fn submit( &self, request: WorkerRequest, ) -> Result<WorkerResponse, WorkerPoolError>
Submits one request to the pool and waits for completion.
Sourcepub async fn health_snapshot(&self) -> Vec<WorkerHealth>
pub async fn health_snapshot(&self) -> Vec<WorkerHealth>
Returns current worker health snapshot.
Sourcepub async fn restart_worker(
&self,
worker_id: &str,
) -> Result<(), WorkerPoolError>
pub async fn restart_worker( &self, worker_id: &str, ) -> Result<(), WorkerPoolError>
Restarts one worker task in place and resets health counters.
Trait Implementations§
Source§impl WorkerPoolClient for WorkerPool
impl WorkerPoolClient for WorkerPool
Source§fn submit<'life0, 'async_trait>(
&'life0 self,
request: WorkerRequest,
) -> Pin<Box<dyn Future<Output = Result<WorkerResponse, WorkerPoolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit<'life0, 'async_trait>(
&'life0 self,
request: WorkerRequest,
) -> Pin<Box<dyn Future<Output = Result<WorkerResponse, WorkerPoolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Submits one request to the underlying worker pool.
Source§fn health_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<WorkerHealth>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<WorkerHealth>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a snapshot of worker health state.
Auto Trait Implementations§
impl !Freeze for WorkerPool
impl !RefUnwindSafe for WorkerPool
impl Send for WorkerPool
impl Sync for WorkerPool
impl Unpin for WorkerPool
impl UnsafeUnpin for WorkerPool
impl !UnwindSafe for WorkerPool
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request