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
This commit is contained in:
parent
8f44e57c72
commit
842e6cff43
47 changed files with 7361 additions and 179 deletions
52
background/comms.go
Normal file
52
background/comms.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue