refactor: re-arrange importer package
1 file changed, 0 insertions(+), 50 deletions(-)
changed files
M internal/importer/importer.go → internal/importer/importer.go
@@ -2,9 +2,6 @@ package importer import ( "context" - "sync" - - "alin.ovh/x/log" "alin.ovh/searchix/internal/config" "alin.ovh/searchix/internal/nix"@@ -19,53 +16,6 @@ type ( ImportSource func(context.Context) (<-chan nix.Importable, <-chan error) ImportDestination func(context.Context, <-chan nix.Importable) <-chan error ) - -func pipe( - ctx context.Context, - log *log.Logger, - src ImportSource, - dst ImportDestination, -) (bool, error) { - wg := sync.WaitGroup{} - - wg.Add(1) - objects, srcErrs := src(ctx) - - wg.Add(1) - dstErrors := dst(ctx, objects) - - var hadObjectErrors bool - var criticalError error - go func() { - for { - select { - case err, running := <-srcErrs: - if !running { - wg.Done() - srcErrs = nil - log.Debug("processing completed") - - continue - } - hadObjectErrors = true - log.Warn("error processing object from source", "error", err) - case err, running := <-dstErrors: - if !running { - wg.Done() - dstErrors = nil - - continue - } - hadObjectErrors = true - log.Warn("error writing object to target", "error", err) - } - } - }() - - wg.Wait() - - return hadObjectErrors, criticalError -} func (imp *Importer) indexSource( ctx context.Context,