Skip to content

fix(macros): aplicar retry/dlq declarados em #[subscriber] ao EventRouter#10

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-99f9
Closed

fix(macros): aplicar retry/dlq declarados em #[subscriber] ao EventRouter#10
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-99f9

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 18, 2026

Bug e impacto

#[subscriber(..., retry = exponential(...), dlq = "...")] parseava os atributos e expunha constantes (RETRY_MAX_ATTEMPTS, etc.), mas o método register() não encadeava EventRouter::with_retry / with_dlq. Em runtime, falhas de handler não eram retentadas nem publicadas na DLQ conforme documentado (US-008 / CHANGELOG), o que pode levar a perda de processamento esperado (mensagens indo para DLQ) ou ausência de backoff.

Causa raiz

O register_body da macro emitia apenas subscribe_with / subscribe_publish, sem pós-processamento que aplica as políticas à última inscrição do router.

Correção

  • Campo retry_specified em SubscriberAttr (distinto do default max=1 / base=0).
  • Função subscriber_router_post_chain que emite with_retry(RetryPolicy::exponential(...).dead_letter(...)) e/ou with_dlq(...) conforme o atributo.
  • Testes em macros_sqs_dlq.rs validando last_retry() / last_dlq() no router após register().

Validação

cargo +nightly test -p serverust-events --features "in-memory sqs" --test macros_sqs_dlq --test macros
cargo +nightly clippy -p serverust-macros --all-targets -- -D warnings
Open in Web View Automation 

O parser já aceitava retry = exponential(...) e dlq = "...", mas o código
gerado em register() só fazia subscribe/subscribe_publish — as políticas
nunca eram ligadas ao router. Falhas não eram retentadas nem enviadas à DLQ
conforme documentado.

- Rastrear retry_specified para distinguir default de retry explícito
- Encadear with_retry / with_dlq / dead_letter na última inscrição
- Testes de introspecção no router (retry-only, dlq-only, ambos)

Co-authored-by: Jaime Basso <JaimeJunr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants