Skip to main content

Crate wabot_feature_async

Crate wabot_feature_async 

Source
Expand description

§wabot-feature-async

Rust port of wabot-ts/src/feature/async. Provides:

§Wiring a process

ⓘ
let c = Container::new();
register_job_repository(&c, Arc::new(InMemoryJobRepository::new()));
register_cron_job_repository(&c, Arc::new(InMemoryCronJobRepository::new()));
register_async_runtime(&c);

tokio::spawn(run_async_workers(
    c.clone(),
    vec![SendEmailHandler::__handler_entry(&c)],
    vec![NightlyCleanupHandler::__cron_entry(&c)],
));

run_command(&c, &SendEmail { to: "a@b.c".into() }).await?;

Re-exports§

pub use command::CommandData;
pub use cron_job::CronJob;
pub use cron_job::CronJobData;
pub use cron_scheduler::CronScheduler;
pub use dedup::compute_dedup_key;
pub use executor::JobExecutor;
pub use handler::CommandHandlerEntry;
pub use handler::CommandInvokeFn;
pub use handler::CronHandlerEntry;
pub use handler::CronInvokeFn;
pub use job::Job;
pub use job::JobData;
pub use locker::InProcessLocker;
pub use registry::CommandRegistry;
pub use registry::CronRegistry;
pub use repository::CronJobRepository;
pub use repository::JobRepository;
pub use runner::JobRunner;
pub use scheduler::register_cron_job_repository;
pub use scheduler::register_job_repository;
pub use scheduler::register_locker;
pub use scheduler::run_command;
pub use scheduler::run_scheduler_loop;
pub use scheduler::schedule_command;
pub use scheduler::schedule_job;
pub use scheduler::AsyncRuntimeConfig;
pub use scheduler::DynCronJobRepository;
pub use scheduler::DynJobRepository;
pub use scheduler::DynLocker;
pub use scheduler::ScheduleAt;
pub use types::handler_error;
pub use types::AsyncError;
pub use types::AsyncResult;
pub use types::DedupConfig;
pub use types::JobOptions;
pub use types::MisfirePolicy;

Modules§

command
The CommandData trait — compile-time link between a command struct and its stable wire name.
cron_job
CronJob entity — a recurring schedule template that spawns one-shot Jobs on its tick. Mirrors CronJob / ICronJobData.
cron_scheduler
CronScheduler — periodic tick + reconciliation that translates cron definitions into queued Jobs.
dedup
Stable dedup-key derivation. Mirrors computeDedupKey in TS — JSON canonicalization → SHA-256 → hex.
executor
JobExecutor — concurrency limiter + per-job dispatch.
handler
Command + cron handler traits.
job
Job entity — one queued/running/finished invocation of a command. Mirrors Job / IJobData in TS.
locker
In-process Locker implementation.
registry
Runtime command + cron registry — the Rust analogue of AsyncMetadataStore. Populated explicitly by user code (via the register_command_handlers! / register_cron_handlers! macros); the scheduler/runner/cron-scheduler read from here.
repository
Repository traits for jobs and cron jobs. Implementations live in addon crates (wabot-addon-async-in-memory, future wabot-addon-async-pg).
runner
JobRunner — execute exactly one Job in isolation.
scheduler
Job scheduling helpers + the polling loop.
types
Shared option / error types used across the async subsystem.

Structs§

JobWatchdog

Traits§

Locker
Object-safe locking trait. Implementations only have to expose acquire / try_acquire; the ergonomic wrappers live on LockerExt, which is blanket-implemented.
LockerExt
Sugar layered on top of Locker. Generic methods can’t live on Locker itself without making it non-dyn-compatible — this extension trait keeps the core dyn-safe while restoring the with_key / try_with_key ergonomics at call sites.

Functions§

cron_command_entry
Adapt a cron entry into the command entry the JobRunner dispatches through when the cron’s queued Job comes up for execution. Wrap a cron entry so the job runner can execute it: a cron tick queues an ordinary Job under the cron’s command name, and the bridge discards the (always-null) payload.
register_async_runtime
Wire every async-subsystem singleton into the container in one call. Run after registering concrete JobRepository / CronJobRepository implementations (see register_job_repository / register_cron_job_repository).
run_async_workers
Boot the scheduler + watchdog + cron-scheduler loops for the given command and cron handler registrations.