I'm settling on the idea that strings should never be returned from the userfile system. Instead, indicate which collection you want and pass objects across.
36 lines
829 B
Go
36 lines
829 B
Go
package background
|
|
|
|
import (
|
|
"context"
|
|
//"fmt"
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform/csv"
|
|
//"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 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 := csv.ProcessJob(job.fileID)
|
|
if err != nil {
|
|
log.Error().Err(err).Int32("id", job.fileID).Msg("Error processing CSV file")
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
}
|