pub struct ActivityRegistry { /* private fields */ }Expand description
Registry of typed activity handlers keyed by activity-type name.
Implementations§
Source§impl ActivityRegistry
impl ActivityRegistry
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 under an activity-type name.
§Errors
Returns WorkerError::Registration when the name is already registered.
Sourcepub fn activity_types(&self) -> BTreeSet<String>
pub fn activity_types(&self) -> BTreeSet<String>
Returns the registered activity-type names in deterministic order.
Trait Implementations§
Source§impl ActivityDispatcher for ActivityRegistry
impl ActivityDispatcher for ActivityRegistry
Source§fn dispatch<'life0, 'async_trait>(
&'life0 self,
task: ActivityTask,
context: ActivityContext,
) -> Pin<Box<dyn Future<Output = Result<DispatchOutcome, WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn dispatch<'life0, 'async_trait>(
&'life0 self,
task: ActivityTask,
context: ActivityContext,
) -> Pin<Box<dyn Future<Output = Result<DispatchOutcome, WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Executes one decoded activity task with the provided handler context.
Source§fn activity_types(&self) -> BTreeSet<String>
fn activity_types(&self) -> BTreeSet<String>
Activity type names this dispatcher can serve.
Source§impl Default for ActivityRegistry
impl Default for ActivityRegistry
Source§fn default() -> ActivityRegistry
fn default() -> ActivityRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ActivityRegistry
impl !UnwindSafe for ActivityRegistry
impl Freeze for ActivityRegistry
impl Send for ActivityRegistry
impl Sync for ActivityRegistry
impl Unpin for ActivityRegistry
impl UnsafeUnpin for ActivityRegistry
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