pub struct WorkerBuilder { /* private fields */ }Expand description
Builder for a configured worker and its registered typed activities.
Implementations§
Source§impl WorkerBuilder
impl WorkerBuilder
Sourcepub fn new(config: WorkerConfig) -> Self
pub fn new(config: WorkerConfig) -> Self
Creates a builder for a worker using the supplied config.
Sourcepub fn register_activity<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
handler: Handler,
) -> Result<Self, WorkerError>where
Input: Serialize + DeserializeOwned + Send + Sync + 'static,
Output: Serialize + Send + Sync + 'static,
Handler: for<'context> Fn(Input, &'context ActivityContext) -> HandlerFuture<'context, Output> + Send + Sync + 'static,
pub fn register_activity<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
handler: Handler,
) -> Result<Self, WorkerError>where
Input: Serialize + DeserializeOwned + Send + Sync + 'static,
Output: Serialize + Send + Sync + 'static,
Handler: for<'context> Fn(Input, &'context ActivityContext) -> HandlerFuture<'context, Output> + Send + Sync + 'static,
Registers one typed activity handler on the builder.
§Errors
Returns WorkerError::Registration when the activity type is duplicate.
Sourcepub fn build(self) -> Result<Worker, WorkerError>
pub fn build(self) -> Result<Worker, WorkerError>
Builds the worker after validating that it has at least one activity.
§Errors
Returns WorkerError::Registration when no activities are registered.
Auto Trait Implementations§
impl !RefUnwindSafe for WorkerBuilder
impl !UnwindSafe for WorkerBuilder
impl Freeze for WorkerBuilder
impl Send for WorkerBuilder
impl Sync for WorkerBuilder
impl Unpin for WorkerBuilder
impl UnsafeUnpin for WorkerBuilder
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> 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