Skip to content

feat(server-go): webhook saliente de alertas con HMAC, retry y DLQ (Fase 8.7b) - #31

Merged
gnacho merged 1 commit into
mainfrom
feat/netpulse-webhook
Aug 6, 2026
Merged

feat(server-go): webhook saliente de alertas con HMAC, retry y DLQ (Fase 8.7b)#31
gnacho merged 1 commit into
mainfrom
feat/netpulse-webhook

Conversation

@gnacho

@gnacho gnacho commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Cierra el issue #30 (Fase 8.7b). Webhook saliente de alertas.

Cambios

  • Nuevo paquete internal/webhook/: Notifier que implementa alerts.Notifier con entrega asíncrona (worker único, cola cap 64). Envía a WEBHOOK_URL con firma X-Webhook-Signature: sha256=<hex> del body crudo, reintentos con backoff exponencial + jitter (4xx no se reintenta salvo 429; 429/5xx sí), y DLQ en tabla webhook_events si se agotan los reintentos. Payload con event_id (idempotencia del receptor).
  • Config (config.go): WEBHOOK_URL, WEBHOOK_SECRET, WEBHOOK_TIMEOUT, WEBHOOK_RETRIES, WEBHOOK_RETRY_DELAY. Sin WEBHOOK_URL → webhook inactivo, comportamiento neutro.
  • main.go: notifier compuesto (notifierChain) que encadena push + webhook al único SetNotifier del motor de alertas. Cierre gracioso de ambos en shutdown.
  • Endpoint admin GET /api/webhook/dlq (RequireAdmin): eventos no entregados (metadatos, cap 50).
  • Tabla webhook_events en el schema.

Verificación

  • Tests nuevos internal/webhook/webhook_test.go (4): firma válida verificable por el receptor, 400 no reintenta (1 request), 500 reintenta (Retries+1) y va a DLQ, 2xx sin DLQ. Plus TestWebhookDLQEndpoint (401 sin sesión, 200 con admin).
  • Go build/vet/tests verdes (suite completa, 11 paquetes).
  • Desplegado en CT 226: servicio activo, 4/4 agentes, /api/webhook/dlq responde {"items":[],"total":0}. Webhook inactivo (sin WEBHOOK_URL en .env) — se activará cuando el usuario configure URL+secreto. Binario desplegado == local (sha e4d7c4bd).

Closes #30

@gnacho
gnacho merged commit e99338c into main Aug 6, 2026
1 check passed
@gnacho
gnacho deleted the feat/netpulse-webhook branch August 6, 2026 10:23
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.

Fase 8.7b — Webhook saliente de alertas (HMAC + retry + DLQ)

1 participant