internal/config: add GO_DISCOVERY_QUEUE_SERVICE
GO_DISCOVERY_QUEUE_SERVICE is added, which is used to determine which
service the tasks queue should send requests to.
Change-Id: I27d29ef9ffcd26a5c45412d5a4bb7832348f219d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239917
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/config/config.go b/internal/config/config.go
index 9f5ca64..cec128a 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -70,6 +70,10 @@
// AppEngine identifiers
ProjectID, ServiceID, VersionID, ZoneID, InstanceID, LocationID string
+ // QueueService is used to identify which service Cloud Tasks queue
+ // should send requests to.
+ QueueService string
+
GaeEnv string
// AppMonitoredResource is the resource for the current GAE app.
@@ -213,11 +217,12 @@
Port: os.Getenv("PORT"),
DebugPort: os.Getenv("DEBUG_PORT"),
// Resolve AppEngine identifiers
- ProjectID: os.Getenv("GOOGLE_CLOUD_PROJECT"),
- ServiceID: os.Getenv("GAE_SERVICE"),
- VersionID: os.Getenv("GAE_VERSION"),
- InstanceID: os.Getenv("GAE_INSTANCE"),
- GaeEnv: os.Getenv("GAE_ENV"),
+ ProjectID: os.Getenv("GOOGLE_CLOUD_PROJECT"),
+ ServiceID: os.Getenv("GAE_SERVICE"),
+ VersionID: os.Getenv("GAE_VERSION"),
+ InstanceID: os.Getenv("GAE_INSTANCE"),
+ GaeEnv: os.Getenv("GAE_ENV"),
+ QueueService: os.Getenv("GO_DISCOVERY_QUEUE_SERVICE"),
// LocationID is essentially hard-coded until we figure out a good way to
// determine it programmatically, but we check an environment variable in
// case it needs to be overridden.
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index cc13d9f..a66365a 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -10,7 +10,6 @@
"context"
"crypto/sha256"
"fmt"
- "os"
"time"
cloudtasks "cloud.google.com/go/cloudtasks/apiv2"
@@ -71,7 +70,7 @@
HttpMethod: taskspb.HttpMethod_POST,
RelativeUri: u,
AppEngineRouting: &taskspb.AppEngineRouting{
- Service: os.Getenv("GAE_SERVICE"),
+ Service: q.cfg.QueueService,
},
},
},