nidus-sync/background/comms.go
Eli Ribble 842e6cff43
Move comms work to background goroutine
This is a sort of random checkpoint of work
 * add schema for tracking messages sent to DB
 * add terms of service and privacy policy for RCS compliance
 * standardize some things about background workers
 * update some missing stuff from generated DB code
2026-01-20 17:10:22 +00:00

52 lines
1.2 KiB
Go

package background
import (
"context"
"github.com/Gleipnir-Technology/nidus-sync/queue"
"github.com/rs/zerolog/log"
)
func StartWorkerEmail(ctx context.Context, channel chan queue.JobEmail) {
go func() {
for {
select {
case <-ctx.Done():
log.Info().Msg("Email worker shutting down.")
return
case job := <-channel:
err := processJobEmail(job)
if err != nil {
log.Error().Err(err).Str("dest", job.Destination).Str("type", string(job.Type)).Msg("Error processing audio file")
}
}
}
}()
}
func StartWorkerSMS(ctx context.Context, channel chan queue.JobSMS) {
go func() {
for {
select {
case <-ctx.Done():
log.Info().Msg("Email worker shutting down.")
return
case job := <-channel:
err := processJobSMS(job)
if err != nil {
log.Error().Err(err).Str("dest", job.Destination).Str("type", string(job.Type)).Msg("Error processing audio file")
}
}
}
}()
}
func processJobEmail(job queue.JobEmail) error {
log.Info().Str("dest", job.Destination).Str("type", string(job.Type)).Msg("Pretend doing email job")
return nil
}
func processJobSMS(job queue.JobSMS) error {
log.Info().Str("dest", job.Destination).Str("type", string(job.Type)).Msg("Pretend doing email job")
return nil
}