Add worker process for CSV import jobs

This commit is contained in:
Eli Ribble 2026-02-08 03:52:39 +00:00
parent f81f8def1c
commit d17c8b8be7
No known key found for this signature in database
2 changed files with 48 additions and 3 deletions

View file

@ -13,9 +13,10 @@ var waitGroup sync.WaitGroup
func Start(ctx context.Context) { func Start(ctx context.Context) {
newOAuthTokenChannel = make(chan struct{}, 10) newOAuthTokenChannel = make(chan struct{}, 10)
channelJobAudio = make(chan jobAudio, 100) // Buffered channel to prevent blocking channelJobAudio = make(chan jobAudio, 100) // Buffered channel to prevent blocking
channelJobEmail = make(chan email.Job, 100) // Buffered channel to prevent blocking channelJobImportCSVPool = make(chan jobImportCSVPool, 100) // Buffered channel to prevent blocking
channelJobText = make(chan text.Job, 100) // Buffered channel to prevent blocking channelJobEmail = make(chan email.Job, 100) // Buffered channel to prevent blocking
channelJobText = make(chan text.Job, 100) // Buffered channel to prevent blocking
waitGroup.Add(1) waitGroup.Add(1)
go func() { go func() {
@ -29,6 +30,12 @@ func Start(ctx context.Context) {
startWorkerAudio(ctx, channelJobAudio) startWorkerAudio(ctx, channelJobAudio)
}() }()
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
startWorkerCSV(ctx, channelJobImportCSVPool)
}()
waitGroup.Add(1) waitGroup.Add(1)
go func() { go func() {
defer waitGroup.Done() defer waitGroup.Done()

38
background/pool.go Normal file
View file

@ -0,0 +1,38 @@
package background
import (
"context"
//"fmt"
//"github.com/Gleipnir-Technology/nidus-sync/userfile"
//"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
// represents a job to import a pool CSV file
type jobImportCSVPool struct {
fileID int32
}
var channelJobImportCSVPool chan jobImportCSVPool
func processCSVJob(file_id int32) error {
return nil
}
func startWorkerCSV(ctx context.Context, channelJobImport chan jobImportCSVPool) {
go func() {
for {
select {
case <-ctx.Done():
log.Info().Msg("CSV worker shutting down.")
return
case job := <-channelJobImport:
log.Info().Int32("id", job.fileID).Msg("Processing CSV job")
err := processCSVJob(job.fileID)
if err != nil {
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
}
}
}
}()
}