boson-macros 0.1.0

Proc macros for Boson work engine (#[boson::task])
Documentation

boson-macros

Proc macros for Boson background work.

Provides #[boson::task] for defining tasks with typed enqueue APIs.

Creating tasks

  1. Annotate an async function with #[boson::task(name = "...")].
  2. First parameter must be Box<dyn ExecutionContext>.
  3. Add crate dependencies (below).
  4. Enqueue with <TaskName>::send_with(actor_json, params) once the worker is running.

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 _;).

Integrating the server

Worker boot — BosonBuilder, .auto_registry(), identity factory, and configure before send_with — is documented on the boson crate 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:

boson-macros = "0.1.0"
quark = { package = "uf-quark", version = "0.1.1" }
boson-runtime = "0.1.0"
boson-core = "0.1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

Or depend on boson with the macro re-exported:

boson = { version = "0.1.0", features = ["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

cargo doc -p boson-macros --no-deps --open