nidus-sync/background/background.go

45 lines
881 B
Go
Raw Permalink Normal View History

package background
import (
"context"
"sync"
)
var waitGroup sync.WaitGroup
func Start(ctx context.Context) {
newOAuthTokenChannel = make(chan struct{}, 10)
channelJobAudio = make(chan jobAudio, 100) // Buffered channel to prevent blocking
channelJobEmail = make(chan jobEmail, 100) // Buffered channel to prevent blocking
channelJobText = make(chan jobText, 100) // Buffered channel to prevent blocking
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
refreshFieldseekerData(ctx, newOAuthTokenChannel)
}()
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
startWorkerAudio(ctx, channelJobAudio)
}()
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
startWorkerEmail(ctx, channelJobEmail)
}()
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
startWorkerText(ctx, channelJobText)
}()
}
func WaitForExit() {
waitGroup.Wait()
}