aboutsummaryrefslogtreecommitdiff
path: root/internal/queue/queue.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2020-06-17 07:43:12 -0400
committerJonathan Amsterdam <jba@google.com>2020-06-17 16:27:43 +0000
commit8c8a3b1d6ee8bdeb5e55b29ac237534268eda90d (patch)
treea8e266fceee6cdcf8866de7cfb316aa45b52bd00 /internal/queue/queue.go
parent4ea5ad96b1650fd6d7a3e597feaa5367458e36d0 (diff)
downloadgo-x-pkgsite-8c8a3b1d6ee8bdeb5e55b29ac237534268eda90d.tar.xz
internal/config: remove global
Remove the `cfg` global and the functions that accessed it. Fixes b/145301722. Change-Id: I58ab9fbd4fc29f66dbc5b120f04c88ee0703ee57 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238437 Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/queue/queue.go')
-rw-r--r--internal/queue/queue.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index d775a634..cc13d9f4 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -120,29 +120,31 @@ type InMemory struct {
sourceClient *source.Client
db *postgres.DB
- queue chan moduleVersion
- sem chan struct{}
- experiments *experiment.Set
+ queue chan moduleVersion
+ sem chan struct{}
+ experiments *experiment.Set
+ appVersionLabel string
}
// NewInMemory creates a new InMemory that asynchronously fetches
// from proxyClient and stores in db. It uses workerCount parallelism to
// execute these fetches.
func NewInMemory(ctx context.Context, proxyClient *proxy.Client, sourceClient *source.Client, db *postgres.DB, workerCount int,
- processFunc func(context.Context, string, string, *proxy.Client, *source.Client, *postgres.DB) (int, error), experiments *experiment.Set) *InMemory {
+ processFunc func(context.Context, string, string, *proxy.Client, *source.Client, *postgres.DB, string) (int, error), experiments *experiment.Set, appVersionLabel string) *InMemory {
q := &InMemory{
- proxyClient: proxyClient,
- sourceClient: sourceClient,
- db: db,
- queue: make(chan moduleVersion, 1000),
- sem: make(chan struct{}, workerCount),
- experiments: experiments,
+ proxyClient: proxyClient,
+ sourceClient: sourceClient,
+ db: db,
+ queue: make(chan moduleVersion, 1000),
+ sem: make(chan struct{}, workerCount),
+ experiments: experiments,
+ appVersionLabel: appVersionLabel,
}
go q.process(ctx, processFunc)
return q
}
-func (q *InMemory) process(ctx context.Context, processFunc func(context.Context, string, string, *proxy.Client, *source.Client, *postgres.DB) (int, error)) {
+func (q *InMemory) process(ctx context.Context, processFunc func(context.Context, string, string, *proxy.Client, *source.Client, *postgres.DB, string) (int, error)) {
for v := range q.queue {
select {
@@ -162,7 +164,7 @@ func (q *InMemory) process(ctx context.Context, processFunc func(context.Context
fetchCtx = experiment.NewContext(fetchCtx, q.experiments)
defer cancel()
- if _, err := processFunc(fetchCtx, v.modulePath, v.version, q.proxyClient, q.sourceClient, q.db); err != nil {
+ if _, err := processFunc(fetchCtx, v.modulePath, v.version, q.proxyClient, q.sourceClient, q.db, q.appVersionLabel); err != nil {
log.Error(fetchCtx, err)
}
}(v)