feat(server-go): webhook saliente de alertas con HMAC, retry y DLQ (Fase 8.7b) - #31
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cierra el issue #30 (Fase 8.7b). Webhook saliente de alertas.
Cambios
internal/webhook/:Notifierque implementaalerts.Notifiercon entrega asíncrona (worker único, cola cap 64). Envía aWEBHOOK_URLcon firmaX-Webhook-Signature: sha256=<hex>del body crudo, reintentos con backoff exponencial + jitter (4xx no se reintenta salvo 429; 429/5xx sí), y DLQ en tablawebhook_eventssi se agotan los reintentos. Payload conevent_id(idempotencia del receptor).config.go):WEBHOOK_URL,WEBHOOK_SECRET,WEBHOOK_TIMEOUT,WEBHOOK_RETRIES,WEBHOOK_RETRY_DELAY. SinWEBHOOK_URL→ webhook inactivo, comportamiento neutro.notifierChain) que encadena push + webhook al únicoSetNotifierdel motor de alertas. Cierre gracioso de ambos en shutdown.GET /api/webhook/dlq(RequireAdmin): eventos no entregados (metadatos, cap 50).webhook_eventsen el schema.Verificación
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. PlusTestWebhookDLQEndpoint(401 sin sesión, 200 con admin)./api/webhook/dlqresponde{"items":[],"total":0}. Webhook inactivo (sin WEBHOOK_URL en .env) — se activará cuando el usuario configure URL+secreto. Binario desplegado == local (shae4d7c4bd).Closes #30