nidus-sync/background/email.go
Eli Ribble 196792810b
Overhaul email sending system
Add logging and saving templates to the database for historical
accuracy.
2026-01-23 20:36:16 +00:00

42 lines
786 B
Go

package background
import (
"context"
"github.com/Gleipnir-Technology/nidus-sync/comms/email"
"github.com/rs/zerolog/log"
)
var channelJobEmail chan email.Job
func ReportSubscriptionConfirmationEmail(destination, report_id string) {
enqueueJobEmail(email.NewJobReportSubscriptionConfirmation(
destination,
report_id,
))
}
func enqueueJobEmail(job email.Job) {
select {
case channelJobEmail <- job:
return
default:
log.Warn().Msg("email job channel is full, dropping job")
}
}
func startWorkerEmail(ctx context.Context, channel chan email.Job) {
go func() {
for {
select {
case <-ctx.Done():
log.Info().Msg("Email worker shutting down.")
return
case job := <-channel:
err := email.Handle(ctx, job)
if err != nil {
}
}
}
}()
}