如何在本地 google 应用引擎环境中创建 pull/push 队列

How to create pull/push queues in local google app engine environment

我需要在本地启动我的 google 应用引擎项目。它在 google 服务器上正常工作,但调试变得很痛苦,因为每次修复都需要花费大量时间。我几乎已经设法在本地启动它,但我不明白如何创建队列,这是必要的。我的步数:

  1. run dev_appserver.py app.yaml,遵循 using local development server 指南。除队列外一切正常:

    _, err := taskqueue.Add(u.Ctx(), task, queueName)
    exceptions.ThrowIfErr(true, "err_msg", err)
    

    投掷

    Panic! UserMessage: <err_msg>, Error: API error 1 (taskqueue: UNKNOWN_QUEUE),...
    
  2. 我可以轻松地在远程服务器上创建队列(使用 creating push and creating pull 指南):

    gcloud app deploy queue.yaml
    

    对于queue.yaml

    queue:
    - name: Pull-Data-Queue
      mode: pull
    
    - name: Push-Data-Queue
      mode: push
      rate: 1/s
    
  3. 我可以打开 http://localhost:8000/datastore 并查看一些创建的数据。
  4. 我可以打开 http://localhost:8000/taskqueue 并看到唯一一个默认推送队列。此处没有添加新队列的工具。

Google 指南说队列不能从代码动态创建,只能通过 yaml 或 xml。但是如何在本地环境中创建它们。有可能吗?据我所知,gcloud app deploy queue.yaml 仅适用于远程部署。

如果 queue.yaml 文件与 app.yaml 文件并排,开发服务器会自动检测到它。可以使用符号链接而不是复制。它解决了问题。