Skip to main content

ActivityRegistry

Struct ActivityRegistry 

Source
pub struct ActivityRegistry { /* private fields */ }
Expand description

Registry of typed activity handlers keyed by activity-type name.

Implementations§

Source§

impl ActivityRegistry

Source

pub fn new() -> Self

Creates an empty activity registry.

Source

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.

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> bool

Returns true when no activity handlers have been registered.

Source

pub fn activity_types(&self) -> BTreeSet<String>

Returns the registered activity-type names in deterministic order.

Source

pub fn activity_descriptors(&self) -> Vec<ActivityDescriptor>

Returns committed typed activity descriptors in deterministic name order.

Trait Implementations§

Source§

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,

Executes one decoded activity task with the provided handler context.
Source§

fn activity_types(&self) -> BTreeSet<String>

Activity type names this dispatcher can serve.
Source§

impl DeclaredCommands for ActivityRegistry

Source§

fn register_declared_command( self, activity_type: impl Into<String>, action: ShellAction, ) -> Result<Self, WorkerError>

Register action to be served under activity_type. Read more
Source§

impl Default for ActivityRegistry

Source§

fn default() -> ActivityRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more