pub struct Worker<S, R = NoopWorkerRegistry> { /* private fields */ }
Expand description
A worker where workers can be registered and are executed whenever tasks are ready.
Implementations§
Source§impl<S> Worker<S>where
S: WorkerStore + 'static,
impl<S> Worker<S>where
S: WorkerStore + 'static,
Sourcepub fn new_with_options(store: S, options: WorkerOptions) -> Self
pub fn new_with_options(store: S, options: WorkerOptions) -> Self
Create a new worker.
Source§impl<S, R> Worker<S, R>
impl<S, R> Worker<S, R>
Sourcepub fn register_handler(
&mut self,
worker: Arc<dyn RawHandler + Send + Sync>,
) -> &mut Self
pub fn register_handler( &mut self, worker: Arc<dyn RawHandler + Send + Sync>, ) -> &mut Self
Register a handler for the worker.
§Panics
Panics if a handler was already registered with a matching WorkerSelector
.
Sourcepub fn with_registry<R2>(self, registry: R2) -> Worker<S, R2>
pub fn with_registry<R2>(self, registry: R2) -> Worker<S, R2>
Set the registry for this worker.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description of this worker.
Sourcepub fn with_version(self, version: impl Into<String>) -> Self
pub fn with_version(self, version: impl Into<String>) -> Self
Set the version of this worker.
Sourcepub fn handle(&self) -> WorkerHandle
pub fn handle(&self) -> WorkerHandle
Get a handle to this worker.
Sourcepub fn handlers(&self) -> impl Iterator<Item = &WorkerSelector>
pub fn handlers(&self) -> impl Iterator<Item = &WorkerSelector>
Get the worker selectors for the handlers registered with this worker.
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
Return the count of handlers registered.
Sourcepub fn metadata(&self) -> &WorkerMetadata
pub fn metadata(&self) -> &WorkerMetadata
Get the metadata for this worker.
Trait Implementations§
Auto Trait Implementations§
impl<S, R> Freeze for Worker<S, R>
impl<S, R = NoopWorkerRegistry> !RefUnwindSafe for Worker<S, R>
impl<S, R> Send for Worker<S, R>
impl<S, R> Sync for Worker<S, R>
impl<S, R> Unpin for Worker<S, R>
impl<S, R = NoopWorkerRegistry> !UnwindSafe for Worker<S, R>
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