boson-macros
Proc macros for Boson background work.
Provides #[boson::task] for defining tasks with typed enqueue APIs.
Creating tasks
- Annotate an async function with
#[boson::task(name = "...")]. - First parameter must be
Box<dyn ExecutionContext>. - Add crate dependencies (below).
- Enqueue with
<TaskName>::send_with(actor_json, params)once the process has calledconfigure(Mode 1 embedded or Mode 2 enqueue host).
Optional policy attributes: priority, pool, idempotency_mode, max_attempts, base_delay_ms,
backoff_multiplier, max_delay_ms, max_in_flight, max_enqueue_per_second — see rustdoc on
task for defaults.
Project setup (once per handler crate)
- Add dependencies (below).
- If handlers live in a library crate, link that crate into the worker binary
(for example
use my_worker as _;).
Boot once (not per task)
Worker / enqueue-host boot — BosonBuilder, .auto_registry(), identity factory, and configure
before send_with — is documented on the boson crate
Getting started and in
boson-runtime. You do not repeat boot steps for each new task.
Runnable first-boot example: task_macro.
Consumer dependencies
Crates that define tasks need:
= "0.1.1"
= { = "uf-quark", = "0.1.1" }
= "0.1.1"
= "0.1.1"
= { = "1", = ["derive"] }
= "1"
Or depend on boson with the macro re-exported:
= { = "uf-boson", = "0.1.1", = ["mem"] }
Identity in handlers
Handlers receive Box<dyn ExecutionContext>. Choosing and installing an
ExecutionContextFactory
happens at worker boot — see boson-core identity docs and
boson-runtime.
Documentation