Rust

hook

Module

Undocumented.

Contents

use utopia_queue::Hook;
Rust
pub struct Hook

A callback with its groups, params and injections.

Rust
use utopia_queue::Hook;

let mut hook = Hook::new();
hook.groups(&["emails"]).inject("message").action(|scope| async move {
    let _message = scope.message();
    Ok(())
});
assert_eq!(hook.group_names(), ["emails"]);
use utopia_queue::Job;
Rust
pub struct Job

The handler of one queue: a Hook whose init and shutdown hooks can be switched off.

Also implements Default, Deref, DerefMut.
use utopia_queue::hook::Param;
Rust
pub struct Param

A param read from the message payload.

use utopia_queue::hook::Resources;
Rust
pub struct Resources

Resources by name, falling back to a parent: the server's resources are the parent of every message's context.

use utopia_queue::hook::Scope;
Rust
pub struct Scope

The arguments a hook's action receives: params by key and injected resources by name, in declaration order.

use utopia_queue::hook::Check;
Rust
pub enum Check

A param's validator: an instance, or a factory given injected resources.

Rust
pub type Action = Arc<dyn Fn(Scope) -> BoxFuture<'static, Result<()>> + Send + Sync>

A hook's callback.

Rust
pub type Resource = Arc<dyn Any + Send + Sync>

An injectable resource.

Rust
pub type ValidatorFactory = Arc<dyn Fn(&[Resource]) -> Arc<dyn Validator> + Send + Sync>

Builds a param's validator from its injected resources.