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 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 a typed handler and mechanically derives its wire contract from the same concrete serde types used at dispatch.
§Errors
Returns WorkerError::Registration for a duplicate name or
WorkerError::Encode if a generated schema cannot be represented as JSON.
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 a typed handler together with an EXPLICIT wire descriptor.
For an activity whose schemas are owned by a declaration rather than by
Rust types, Self::register_activity_with_contract cannot help: there
is no schemars type to derive from, because the types live in the
.awl document. The handler is therefore untyped (serde_json::Value
in and out) while the advertisement is exact, supplied by whoever read
the declaration.
Registering a handler with no descriptor is what makes a worker invisible to contract admission — it advertises nothing, and a queue carrying any deployed contract refuses it. This is the path that keeps a declaration-driven worker admissible.
§Errors
Returns WorkerError::Registration when the name is already
registered, or when descriptor names a different activity than
activity_type — a descriptor advertised under the wrong name would
promise one action’s schema for another’s handler.
Sourcepub fn activity_types(&self) -> BTreeSet<String>
pub fn activity_types(&self) -> BTreeSet<String>
Returns the registered activity-type names in deterministic order.
Sourcepub fn activity_descriptors(&self) -> Vec<ActivityDescriptor>
pub fn activity_descriptors(&self) -> Vec<ActivityDescriptor>
Returns committed typed activity descriptors in deterministic name 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,
Source§fn activity_types(&self) -> BTreeSet<String>
fn activity_types(&self) -> BTreeSet<String>
Source§impl DeclaredCommands for ActivityRegistry
impl DeclaredCommands for ActivityRegistry
Source§fn register_declared_command(
self,
activity_type: impl Into<String>,
action: ShellAction,
) -> Result<Self, WorkerError>
fn register_declared_command( self, activity_type: impl Into<String>, action: ShellAction, ) -> Result<Self, WorkerError>
Source§impl Default for ActivityRegistry
impl Default for ActivityRegistry
Source§fn default() -> ActivityRegistry
fn default() -> ActivityRegistry
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
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