diff options
| author | Jonathan Amsterdam <jba@google.com> | 2020-02-21 09:39:09 -0500 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-04-06 15:50:52 -0400 |
| commit | cfcdc5826a9e22c349b4d30e48649a0663941bd4 (patch) | |
| tree | b4857817d0f6376e7573cba019776d9fcbca4de2 /internal/queue/queue.go | |
| parent | 6a38d1c399d76d3ed0736258c78d1e38819e97c1 (diff) | |
| download | go-x-pkgsite-cfcdc5826a9e22c349b4d30e48649a0663941bd4.tar.xz | |
internal/config: make more stateless
As per the bug listed below, we are trying to remove the global cfg
variable from the config package. This CL brings us close to that
goal. There are still two uses of the global that are harder to remove.
Updates b/145301722.
Change-Id: Ia6c350ef5d817ff7fb3125cd207343d10911d64f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/672580
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'internal/queue/queue.go')
| -rw-r--r-- | internal/queue/queue.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go index c4b6a9ac..045b0df5 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -31,6 +31,7 @@ type Queue interface { // GCP provides a Queue implementation backed by the Google Cloud Tasks // API. type GCP struct { + cfg *config.Config client *cloudtasks.Client queueID string } @@ -38,7 +39,7 @@ type GCP struct { // NewGCP returns a new Queue that can be used to enqueue tasks using the // cloud tasks API. The given queueID should be the name of the queue in the // cloud tasks console. -func NewGCP(client *cloudtasks.Client, queueID string) *GCP { +func NewGCP(cfg *config.Config, client *cloudtasks.Client, queueID string) *GCP { return &GCP{ client: client, queueID: queueID, @@ -52,7 +53,7 @@ func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix str // the new taskqueue API requires a deadline of <= 30s ctx, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() - queueName := fmt.Sprintf("projects/%s/locations/%s/queues/%s", config.ProjectID(), config.LocationID(), q.queueID) + queueName := fmt.Sprintf("projects/%s/locations/%s/queues/%s", q.cfg.ProjectID, q.cfg.LocationID, q.queueID) u := fmt.Sprintf("/fetch/%s/@v/%s", modulePath, version) taskID := newTaskID(modulePath, version, time.Now()) req := &taskspb.CreateTaskRequest{ |
