Expand description
The worker every Puerto project with domain events runs (ADR-0018 § 5): the relay that moves the outbox onto the transport, one consume loop per consumer, the health probes and graceful shutdown.
It only sees the transport ports of puerto_nucleo::eventos::transporte: the project’s
presentacion/worker/src/generado/registro.rs hands it the adapters (puerto_sqlx::eventos
for the db transport) and its consumers.
ⓘ
pub async fn construir_worker(config: ConfigWorker) -> Result<Bucles, String> {
Ok(Bucles::new(&config)
.relay(OutboxPostgres::new(pool.clone()), entregas)
.consumidor(
SuscripcionPostgres::new(pool.clone(), "avisar_producto_nuevo"),
AvisarProductoNuevo,
descartados,
))
}Re-exports§
pub use conductor::Progreso;pub use config::ConfigWorker;pub use consumidor::Consumidor;pub use relay::Relay;pub use worker::Bucles;pub use worker::Worker;
Modules§
- conductor
- What turns a relay or a consumer into a loop: pass after pass, a pause when there is nothing
to do, a heartbeat for
/health/ready, and a clean stop on shutdown. - config
- The worker’s configuration, read once at startup from the environment (and
.env). - consumidor
- A consume loop: hands each delivery of one subscription to its handler and settles it with the delivery policy (ADR-0018 § 4, § 6).
- relay
- The relay: moves what the API’s units of work wrote to the outbox onto the transport, in the order it was written (ADR-0018 § 5).
- worker
- The worker process: the relay and every consumer as loops, the health probes and graceful shutdown (ADR-0018 § 5, ADR-0008).
Enums§
- Error
- Why the application did not start or stopped serving.
- Error
Config - A configuration variable that is set to a value the application cannot use.