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 register_activity_with_contract<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
handler: Handler,
) -> Result<Self, WorkerError>where
Input: Serialize + DeserializeOwned + JsonSchema + Send + Sync + 'static,
Output: Serialize + JsonSchema + Send + Sync + 'static,
Handler: for<'context> Fn(Input, &'context ActivityContext) -> HandlerFuture<'context, Output> + Send + Sync + 'static,
pub fn register_activity_with_contract<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
handler: Handler,
) -> Result<Self, WorkerError>where
Input: Serialize + DeserializeOwned + JsonSchema + Send + Sync + 'static,
Output: Serialize + JsonSchema + Send + Sync + 'static,
Handler: for<'context> Fn(Input, &'context ActivityContext) -> HandlerFuture<'context, Output> + Send + Sync + 'static,
Registers one typed activity and commits mechanically derived schemas to every registration handshake.
§Errors
Returns WorkerError for duplicate activity names or schema encoding.
Sourcepub fn register_activity_with_descriptor<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
descriptor: ActivityDescriptor,
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_with_descriptor<Input, Output, Handler>(
self,
activity_type: impl Into<String>,
descriptor: ActivityDescriptor,
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 activity with an EXPLICIT wire descriptor, for schemas owned by a declaration rather than by Rust types.
See ActivityRegistry::register_activity_with_descriptor: this is how a
declaration-driven worker (one whose types live in an .awl document)
advertises a real action surface instead of an empty one.
§Errors
Returns WorkerError::Registration for a duplicate activity name or a
descriptor naming a different activity.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
T in a tonic::Request