Run webhook sender on the kit worker framework

Convert the hand-rolled webhook Sender loop into a kit worker.Handler so
the sender gets the standard worker recovery, metrics and tracing
instead. Claim loads the next unprocessed webhook data and Process
performs the deliveries; behaviour is preserved with a single-concurrency
worker on the existing poll interval.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
Sacha Al Himdani
2026-06-23 09:53:52 +02:00
parent 14f52f0ef4
commit 1948142e7a
2 changed files with 76 additions and 59 deletions

View File

@@ -713,8 +713,8 @@ func (impl *Implm) Run(
},
)
webhookSenderCtx, stopWebhookSender := context.WithCancel(context.Background())
webhookSender := webhook.NewSender(pgClient, l.Named("webhook-sender"), webhook.Config{
webhookWorkerCtx, stopWebhookWorker := context.WithCancel(context.Background())
webhookWorker := webhook.NewWebhookWorker(pgClient, l.Named("webhook-sender"), webhook.Config{
Interval: time.Duration(impl.cfg.Notifications.Webhook.SenderInterval) * time.Second,
CacheTTL: time.Duration(impl.cfg.Notifications.Webhook.CacheTTL) * time.Second,
EncryptionKey: encryptionKey,
@@ -723,8 +723,8 @@ func (impl *Implm) Run(
wg.Go(
func() {
if err := webhookSender.Run(webhookSenderCtx); err != nil {
cancel(fmt.Errorf("webhook sender crashed: %w", err))
if err := webhookWorker.Run(webhookWorkerCtx); err != nil {
cancel(fmt.Errorf("webhook worker crashed: %w", err))
}
},
)
@@ -1002,7 +1002,7 @@ func (impl *Implm) Run(
stopApiServer()
stopTrustCenterServer()
stopWebhookSender()
stopWebhookWorker()
stopESignService()
stopTrackerPatternAnalysisWorker()
stopTrackerPolicyWorker()