mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
catalog: clean up unused interfaces (#1027)
* catalog: clean up unused interfaces * fix op name
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/gomods/athens/pkg/download"
|
||||
"github.com/gomods/athens/pkg/errors"
|
||||
"github.com/gomods/athens/pkg/paths"
|
||||
"github.com/gomods/athens/pkg/storage"
|
||||
)
|
||||
|
||||
@@ -128,21 +127,3 @@ func (p *withpool) Zip(ctx context.Context, mod, ver string) (io.ReadCloser, err
|
||||
}
|
||||
return zip, nil
|
||||
}
|
||||
|
||||
func (p *withpool) Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error) {
|
||||
const op errors.Op = "pool.Catalog"
|
||||
var modsVers []paths.AllPathParams
|
||||
var nextToken string
|
||||
var err error
|
||||
done := make(chan struct{}, 1)
|
||||
p.jobCh <- func() {
|
||||
modsVers, nextToken, err = p.dp.Catalog(ctx, token, pageSize)
|
||||
close(done)
|
||||
}
|
||||
<-done
|
||||
if err != nil {
|
||||
return nil, "", errors.E(op, err)
|
||||
}
|
||||
|
||||
return modsVers, nextToken, nil
|
||||
}
|
||||
|
||||
@@ -152,11 +152,6 @@ func (m *mockDP) Zip(ctx context.Context, mod, ver string) (io.ReadCloser, error
|
||||
return m.zip, m.err
|
||||
}
|
||||
|
||||
// Catalog implements GET /catalog
|
||||
func (m *mockDP) Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error) {
|
||||
return m.catalog, "", m.err
|
||||
}
|
||||
|
||||
// Version is a helper method to get Info, GoMod, and Zip together.
|
||||
func (m *mockDP) Version(ctx context.Context, mod, ver string) (*storage.Version, error) {
|
||||
panic("skipped")
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/gomods/athens/pkg/errors"
|
||||
"github.com/gomods/athens/pkg/observ"
|
||||
"github.com/gomods/athens/pkg/paths"
|
||||
"github.com/gomods/athens/pkg/stash"
|
||||
"github.com/gomods/athens/pkg/storage"
|
||||
)
|
||||
@@ -29,9 +28,6 @@ type Protocol interface {
|
||||
|
||||
// Zip implements GET /{module}/@v/{version}.zip
|
||||
Zip(ctx context.Context, mod, ver string) (io.ReadCloser, error)
|
||||
|
||||
// Catalog implements GET /catalog
|
||||
Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error)
|
||||
}
|
||||
|
||||
// Wrapper helps extend the main protocol's functionality with addons.
|
||||
@@ -177,19 +173,6 @@ func (p *protocol) Zip(ctx context.Context, mod, ver string) (io.ReadCloser, err
|
||||
return zip, nil
|
||||
}
|
||||
|
||||
func (p *protocol) Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error) {
|
||||
const op errors.Op = "protocol.Catalog"
|
||||
ctx, span := observ.StartSpan(ctx, op.String())
|
||||
defer span.End()
|
||||
modulesAndVersions, newToken, err := p.storage.Catalog(ctx, token, pageSize)
|
||||
|
||||
if err != nil {
|
||||
return nil, "", errors.E(op, err)
|
||||
}
|
||||
|
||||
return modulesAndVersions, newToken, err
|
||||
}
|
||||
|
||||
// union concatenates two version lists and removes duplicates
|
||||
func union(list1, list2 []string) []string {
|
||||
if list1 == nil {
|
||||
|
||||
Reference in New Issue
Block a user