Google app engine GAE Golang-如何正确地将任务队列安排到后端?

Google app engine GAE Golang-如何正确地将任务队列安排到后端?,google-app-engine,scheduled-tasks,go,backend,Google App Engine,Scheduled Tasks,Go,Backend,关于如何在Go中的GoogleAppEngine中将任务队列安排到后端的信息很少。在这方面,我们可以阅读: // Additional HTTP headers to pass at the task's execution time. // To schedule the task to be run with an alternate app version // or backend, set the "Host" header. Header http.Header 但对于如何真正设置

关于如何在Go中的GoogleAppEngine中将任务队列安排到后端的信息很少。在这方面,我们可以阅读:

// Additional HTTP headers to pass at the task's execution time.
// To schedule the task to be run with an alternate app version
// or backend, set the "Host" header.
Header http.Header
但对于如何真正设置“主机”没有任何解释。在后端概述中,我们可以类似地阅读:

应用程序管理员、应用程序实例以及应用程序引擎API和服务(如任务队列任务和Cron作业)无需任何特殊配置即可访问专用后端

但同样,没有给出任何解释

我尝试将“Host”值设置为后端的名称,但任务由普通应用程序执行

t := taskqueue.NewPOSTTask("/", map[string][]string{"key": {key}})
t.Header.Add("Host", "backend")
if _, err := taskqueue.Add(c, t, ""); err != nil {
    return
}

在GAE Go中,安排后端调用的正确方法是什么?

使用命名队列以后端为目标最简单。e、 g:

_, err = taskqueue.Add(c, &taskqueue.Task{
    Path:    "/myProcessorPath",
    Payload: myPayload,
}, "myQueueName")
队列定义指定后端。e、 g.对于
myQueueName
,您可能有一个
queue.yaml
条目,如下所示:

- name: myQueueName
  target: myBackendName
  rate: 400/s
  max_concurrent_requests: 64
  bucket_size: 25
  retry_parameters:
    task_age_limit: 7d

使用
appengine.BackendHostname
函数获取后端的主机名。这应该可用作任务的主机标题。

您的问题帮助我理解我误读了文档,NewPOSTTask只是创建了一个任务,但没有发布它。简化了我的代码。谢谢。:)