Expand description
§wabot-feature-async
Rust port of wabot-ts/src/feature/async. Provides:
Job/CronJobentities + state transitions.JobRepository/CronJobRepositorytraits (implementations in addon crates such aswabot-addon-async-in-memory).CommandRegistry/CronRegistry— the Rust analogue ofAsyncMetadataStore, populated byrun_async_workersfrom the handler entries the#[command_handler]/#[cron_handler]macros emit.- Long-running loops:
run_scheduler_loop,JobExecutor,JobRunner,JobWatchdog,CronScheduler. - Per-key
Locker—InProcessLockertoday; Phase 5b adds a Postgres-backed variant, swapped in viaregister_locker. run_command/schedule_commandfor enqueueing a typed command (TS:Async.runCommand/Async.scheduleCommand).
§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
CommandDatatrait — compile-time link between a command struct and its stable wire name. - cron_
job CronJobentity — a recurring schedule template that spawns one-shotJobs on its tick. MirrorsCronJob/ICronJobData.- cron_
scheduler CronScheduler— periodic tick + reconciliation that translates cron definitions into queued Jobs.- dedup
- Stable dedup-key derivation. Mirrors
computeDedupKeyin TS — JSON canonicalization → SHA-256 → hex. - executor
JobExecutor— concurrency limiter + per-job dispatch.- handler
- Command + cron handler traits.
- job
Jobentity — one queued/running/finished invocation of a command. MirrorsJob/IJobDatain TS.- locker
- In-process
Lockerimplementation. - registry
- Runtime command + cron registry — the Rust analogue of
AsyncMetadataStore. Populated explicitly by user code (via theregister_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, futurewabot-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§
Traits§
- Locker
- Object-safe locking trait. Implementations only have to expose
acquire/try_acquire; the ergonomic wrappers live onLockerExt, which is blanket-implemented. - Locker
Ext - Sugar layered on top of
Locker. Generic methods can’t live onLockeritself without making it non-dyn-compatible — this extension trait keeps the core dyn-safe while restoring thewith_key/try_with_keyergonomics at call sites.
Functions§
- cron_
command_ entry - Adapt a cron entry into the command entry the
JobRunnerdispatches 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 ordinaryJobunder 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/CronJobRepositoryimplementations (seeregister_job_repository/register_cron_job_repository). - run_
async_ workers - Boot the scheduler + watchdog + cron-scheduler loops for the given command and cron handler registrations.