pub struct TaskRegistry { /* private fields */ }Expand description
Registry mapping task names to type-erased handlers.
Implementations§
Source§impl TaskRegistry
impl TaskRegistry
pub fn new() -> TaskRegistry
Sourcepub fn get(
&self,
name: &str,
) -> Option<&Arc<dyn Fn(Value, Arc<TaskContext>) -> Pin<Box<dyn Future<Output = Result<Value, KojinError>> + Send>> + Sync + Send>>
pub fn get( &self, name: &str, ) -> Option<&Arc<dyn Fn(Value, Arc<TaskContext>) -> Pin<Box<dyn Future<Output = Result<Value, KojinError>> + Send>> + Sync + Send>>
Look up a handler by task name.
Sourcepub async fn dispatch(
&self,
name: &str,
payload: Value,
ctx: Arc<TaskContext>,
) -> Result<Value, KojinError>
pub async fn dispatch( &self, name: &str, payload: Value, ctx: Arc<TaskContext>, ) -> Result<Value, KojinError>
Execute a task by name with the given payload.
Trait Implementations§
Source§impl Clone for TaskRegistry
impl Clone for TaskRegistry
Source§fn clone(&self) -> TaskRegistry
fn clone(&self) -> TaskRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for TaskRegistry
impl Default for TaskRegistry
Source§fn default() -> TaskRegistry
fn default() -> TaskRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TaskRegistry
impl !RefUnwindSafe for TaskRegistry
impl Send for TaskRegistry
impl Sync for TaskRegistry
impl Unpin for TaskRegistry
impl UnsafeUnpin for TaskRegistry
impl !UnwindSafe for TaskRegistry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more