all repos — searchix @ c28286cee9f8a163051279f7e741d0e4e8d41737

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: make importer.process a method

Alan Pearce
commit

c28286cee9f8a163051279f7e741d0e4e8d41737

parent

21e9e778cc6be3c8717cd4286bedd17f2b22282a

2 files changed, 6 insertions(+), 9 deletions(-)

changed files
M internal/importer/importer.gointernal/importer/importer.go
@@ -6,18 +6,15 @@ "sync"
"alin.ovh/searchix/internal/index" "alin.ovh/searchix/internal/nix" - "alin.ovh/x/log" ) type Processor interface { Process(context.Context) (<-chan nix.Importable, <-chan error) } -func process( +func (imp *Importer) process( ctx context.Context, - indexer *index.WriteIndex, processor Processor, - logger *log.Logger, ) (bool, error) { wg := sync.WaitGroup{}
@@ -25,7 +22,7 @@ wg.Add(1)
objects, pErrs := processor.Process(ctx) wg.Add(1) - iErrs := indexer.Import(ctx, objects) + iErrs := imp.options.WriteIndex.Import(ctx, objects) var hadObjectErrors bool var criticalError error
@@ -36,7 +33,7 @@ case err, running := <-iErrs:
if !running { wg.Done() iErrs = nil - logger.Debug("ingest completed") + imp.options.Logger.Debug("ingest completed") continue }
@@ -47,7 +44,7 @@
break } hadObjectErrors = true - logger.Warn("error ingesting object", "error", err) + imp.options.Logger.Warn("error ingesting object", "error", err) case err, running := <-pErrs: if !running { wg.Done()
@@ -56,7 +53,7 @@
continue } hadObjectErrors = true - logger.Warn("error processing object", "error", err) + imp.options.Logger.Warn("error processing object", "error", err) } } }()
M internal/importer/main.gointernal/importer/main.go
@@ -183,7 +183,7 @@ if err != nil {
return fault.Wrap(err, fmsg.Withf("failed to create processor")) } - hadWarnings, err := process(ctx, imp.options.WriteIndex, processor, logger) + hadWarnings, err := imp.process(ctx, processor) if err != nil { return fault.Wrap(err, fmsg.Withf("failed to process source")) }