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
38
queue/comms.go
Normal file
38
queue/comms.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package queue
|
||||
|
||||
import (
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type JobEmail struct {
|
||||
Destination string
|
||||
Source string
|
||||
Type enums.CommsEmailmessagetype
|
||||
}
|
||||
type JobSMS struct {
|
||||
Destination string
|
||||
Source string
|
||||
Type enums.CommsSmsmessagetype
|
||||
}
|
||||
|
||||
var ChannelJobEmail chan JobEmail
|
||||
var ChannelJobSMS chan JobSMS
|
||||
|
||||
func EnqueueJobEmail(job JobEmail) {
|
||||
select {
|
||||
case ChannelJobEmail <- job:
|
||||
log.Info().Str("destination", job.Destination).Msg("Enqueued email job")
|
||||
default:
|
||||
log.Warn().Msg("email job channel is full, dropping job")
|
||||
}
|
||||
}
|
||||
|
||||
func EnqueueJobSMS(job JobSMS) {
|
||||
select {
|
||||
case ChannelJobSMS <- job:
|
||||
log.Info().Str("destination", job.Destination).Msg("Enqueued sms job")
|
||||
default:
|
||||
log.Warn().Msg("sms job channel is full, dropping job")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue