Add worker process for CSV import jobs
This commit is contained in:
parent
f81f8def1c
commit
d17c8b8be7
2 changed files with 48 additions and 3 deletions
38
background/pool.go
Normal file
38
background/pool.go
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue