Migrate Slack sender to kit worker
Replace the custom polling loop in the Slack sender with the go.gearno.de/kit/worker framework, matching the email sending worker. Add a processing_started_at column to slack_messages so claims are safe under the worker's claim/process model, with stale recovery for crashed in-flight sends. Rename sender.go to worker.go to match the kit worker file naming convention. Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
@@ -701,14 +701,19 @@ func (impl *Implm) Run(
|
||||
)
|
||||
|
||||
slackSenderCtx, stopSlackSender := context.WithCancel(context.Background())
|
||||
slackSender := slack.NewSender(pgClient, l.Named("slack-sender"), encryptionKey, slack.Config{
|
||||
Interval: time.Duration(impl.cfg.Notifications.Slack.SenderInterval) * time.Second,
|
||||
})
|
||||
slackSendingWorker := slack.NewSendingWorker(
|
||||
pgClient,
|
||||
l.Named("slack-sending-worker"),
|
||||
encryptionKey,
|
||||
nil,
|
||||
worker.WithInterval(time.Duration(impl.cfg.Notifications.Slack.SenderInterval)*time.Second),
|
||||
worker.WithMaxConcurrency(1),
|
||||
)
|
||||
|
||||
wg.Go(
|
||||
func() {
|
||||
if err := slackSender.Run(slackSenderCtx); err != nil {
|
||||
cancel(fmt.Errorf("slack sender crashed: %w", err))
|
||||
if err := slackSendingWorker.Run(slackSenderCtx); err != nil {
|
||||
cancel(fmt.Errorf("slack sending worker crashed: %w", err))
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user