aboutsummaryrefslogtreecommitdiff
path: root/internal/queue/queue.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-09-09 13:24:31 -0400
committerJulie Qiu <julie@golang.org>2021-09-13 16:08:37 +0000
commit94f09d6ddbff952b599b69f533c8f29cd76df77d (patch)
tree4d736e58fc9be13f31daa11a7c59a7bf7b2414b5 /internal/queue/queue.go
parente13eb84a023012b1f045b2768b17cc1becbd849e (diff)
downloadgo-x-pkgsite-94f09d6ddbff952b599b69f533c8f29cd76df77d.tar.xz
internal: add frontend fetch source
Frontend fetch requests now have a source=fetch query param. This query param will be used in the next CL to update module_version_states correctly. Change-Id: I658ccea9fba7583838f8ccf733e2862966aef86d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/348816 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/queue/queue.go')
-rw-r--r--internal/queue/queue.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index b8f9e76d..8c1c37b0 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -152,6 +152,10 @@ type Options struct {
// Suffix is used to force reprocessing of tasks that would normally be
// de-duplicated. It is appended to the task name.
Suffix string
+
+ // Source is the source that requested the task to be queued. It is
+ // either "frontend" or the empty string if it is the worker.
+ Source string
}
// Maximum timeout for HTTP tasks.
@@ -161,14 +165,24 @@ const maxCloudTasksTimeout = 30 * time.Minute
const (
DisableProxyFetchParam = "proxyfetch"
DisableProxyFetchValue = "off"
+ SourceParam = "source"
+ SourceFrontendValue = "frontend"
)
func (q *GCP) newTaskRequest(modulePath, version string, opts *Options) *taskspb.CreateTaskRequest {
taskID := newTaskID(modulePath, version)
relativeURI := fmt.Sprintf("/fetch/%s/@v/%s", modulePath, version)
+ var params []string
+ if opts.Source != "" {
+ params = append(params, fmt.Sprintf("%s=%s", SourceParam, opts.Source))
+ }
if opts.DisableProxyFetch {
- relativeURI += fmt.Sprintf("?%s=%s", DisableProxyFetchParam, DisableProxyFetchValue)
+ params = append(params, fmt.Sprintf("%s=%s", DisableProxyFetchParam, DisableProxyFetchValue))
}
+ if len(params) > 0 {
+ relativeURI += fmt.Sprintf("?%s", strings.Join(params, "&"))
+ }
+
task := &taskspb.Task{
Name: fmt.Sprintf("%s/tasks/%s", q.queueName, taskID),
DispatchDeadline: ptypes.DurationProto(maxCloudTasksTimeout),