diff options
Diffstat (limited to 'internal/importer')
-rw-r--r-- | internal/importer/importer.go | 7 | ||||
-rw-r--r-- | internal/importer/main.go | 8 | ||||
-rw-r--r-- | internal/importer/options.go | 8 | ||||
-rw-r--r-- | internal/importer/package.go | 13 | ||||
-rw-r--r-- | internal/importer/utils.go | 8 |
5 files changed, 22 insertions, 22 deletions
diff --git a/internal/importer/importer.go b/internal/importer/importer.go index 0b2db43..9334f7d 100644 --- a/internal/importer/importer.go +++ b/internal/importer/importer.go @@ -4,13 +4,14 @@ import ( "context" "sync" + "gitlab.com/tozd/go/errors" "go.alanpearce.eu/searchix/internal/index" "go.alanpearce.eu/searchix/internal/nix" "go.alanpearce.eu/x/log" ) type Processor interface { - Process(context.Context) (<-chan nix.Importable, <-chan error) + Process(context.Context) (<-chan nix.Importable, <-chan errors.E) } func process( @@ -18,7 +19,7 @@ func process( indexer *index.WriteIndex, processor Processor, logger *log.Logger, -) (bool, error) { +) (bool, errors.E) { wg := sync.WaitGroup{} wg.Add(1) @@ -28,7 +29,7 @@ func process( iErrs := indexer.Import(ctx, objects) var hadObjectErrors bool - var criticalError error + var criticalError errors.E go func() { for { select { diff --git a/internal/importer/main.go b/internal/importer/main.go index 7181926..e2c222c 100644 --- a/internal/importer/main.go +++ b/internal/importer/main.go @@ -14,7 +14,7 @@ import ( "go.alanpearce.eu/searchix/internal/programs" "go.alanpearce.eu/x/log" - "github.com/pkg/errors" + "gitlab.com/tozd/go/errors" ) func createSourceImporter( @@ -23,8 +23,8 @@ func createSourceImporter( meta *index.Meta, indexer *index.WriteIndex, forceUpdate bool, -) func(*config.Source) error { - return func(source *config.Source) error { +) func(*config.Source) errors.E { + return func(source *config.Source) errors.E { logger := log.With( "name", source.Key, @@ -165,7 +165,7 @@ func (imp *Importer) Start( ctx context.Context, forceUpdate bool, onlyUpdateSources *[]string, -) error { +) errors.E { if len(imp.config.Importer.Sources) == 0 { imp.log.Info("No sources enabled") diff --git a/internal/importer/options.go b/internal/importer/options.go index 763f57f..a586a3f 100644 --- a/internal/importer/options.go +++ b/internal/importer/options.go @@ -11,7 +11,7 @@ import ( "github.com/bcicen/jstream" "github.com/mitchellh/mapstructure" - "github.com/pkg/errors" + "gitlab.com/tozd/go/errors" ) type nixValueJSON struct { @@ -68,7 +68,7 @@ func NewOptionProcessor( infile io.ReadCloser, source *config.Source, log *log.Logger, -) (*OptionIngester, error) { +) (*OptionIngester, errors.E) { i := OptionIngester{ dec: jstream.NewDecoder(infile, 1).EmitKV(), log: log, @@ -94,9 +94,9 @@ func NewOptionProcessor( return &i, nil } -func (i *OptionIngester) Process(ctx context.Context) (<-chan nix.Importable, <-chan error) { +func (i *OptionIngester) Process(ctx context.Context) (<-chan nix.Importable, <-chan errors.E) { results := make(chan nix.Importable) - errs := make(chan error) + errs := make(chan errors.E) go func() { defer i.infile.Close() diff --git a/internal/importer/package.go b/internal/importer/package.go index 59bccd8..34293a7 100644 --- a/internal/importer/package.go +++ b/internal/importer/package.go @@ -14,7 +14,7 @@ import ( "github.com/bcicen/jstream" "github.com/mitchellh/mapstructure" - "github.com/pkg/errors" + "gitlab.com/tozd/go/errors" ) type packageJSON struct { @@ -69,7 +69,7 @@ func NewPackageProcessor( source *config.Source, log *log.Logger, programsDB *programs.DB, -) (*PackageIngester, error) { +) (*PackageIngester, errors.E) { i := &PackageIngester{ dec: jstream.NewDecoder(infile, 2).EmitKV(), log: log, @@ -116,9 +116,9 @@ func convertToLicense(in map[string]any) *nix.License { return l } -func (i *PackageIngester) Process(ctx context.Context) (<-chan nix.Importable, <-chan error) { +func (i *PackageIngester) Process(ctx context.Context) (<-chan nix.Importable, <-chan errors.E) { results := make(chan nix.Importable) - errs := make(chan error) + errs := make(chan errors.E) if i.programs != nil { err := i.programs.Open() @@ -135,7 +135,7 @@ func (i *PackageIngester) Process(ctx context.Context) (<-chan nix.Importable, < outer: for mv := range i.dec.Stream() { - var err error + var err errors.E var programs []string select { case <-ctx.Done(): @@ -222,8 +222,7 @@ func (i *PackageIngester) Process(ctx context.Context) (<-chan nix.Importable, < } i.pkg = packageJSON{} - err = i.ms.Decode(x) // stores in i.pkg - if err != nil { + if err := i.ms.Decode(x); err != nil { // stores in i.pkg errs <- errors.WithMessagef(err, "failed to decode package %#v", x) continue diff --git a/internal/importer/utils.go b/internal/importer/utils.go index da10735..0ca6890 100644 --- a/internal/importer/utils.go +++ b/internal/importer/utils.go @@ -10,7 +10,7 @@ import ( "go.alanpearce.eu/searchix/internal/nix" "github.com/bcicen/jstream" - "github.com/pkg/errors" + "gitlab.com/tozd/go/errors" ) func ValueTypeToString(valueType jstream.ValueType) string { @@ -34,7 +34,7 @@ func ValueTypeToString(valueType jstream.ValueType) string { return "very strange" } -func makeRepoURL(repo config.Repository, subPath string, line string) (string, error) { +func makeRepoURL(repo config.Repository, subPath string, line string) (string, errors.E) { switch repo.Type { case config.GitHub: ref := repo.Revision @@ -55,7 +55,7 @@ func makeRepoURL(repo config.Repository, subPath string, line string) (string, e } } -func MakeChannelLink(repo config.Repository, subPath string) (*nix.Link, error) { +func MakeChannelLink(repo config.Repository, subPath string) (*nix.Link, errors.E) { url, err := makeRepoURL(repo, subPath, "") if err != nil { return nil, err @@ -67,7 +67,7 @@ func MakeChannelLink(repo config.Repository, subPath string) (*nix.Link, error) }, nil } -func setRepoRevision(file io.ReadCloser, source *config.Source) error { +func setRepoRevision(file io.ReadCloser, source *config.Source) errors.E { if file != nil { defer file.Close() var str strings.Builder |