Google 的文档忽略了最重要的方面:如何创建任务。任何人都可以完成示例代码:
import (
"appengine/datastore"
"appengine/taskqueue"
)
func f(c appengine.Context) {
err := datastore.RunInTransaction(c, func(c appengine.Context) error {
t := ... // WHY DOES GOOGLE NOT EXPLAIN THIS PART???
// Use the transaction's context when invoking taskqueue.Add.
_, err := taskqueue.Add(c, t, "")
// ...
})
// ...
}
最佳答案
我认为 datastore transactions 的文档中描述了您需要的内容.
所以缺少创建任务的代码是:
t := &taskqueue.Task{Path: "/path/to/workertask"}
关于google-app-engine - 如何在 Go 中为 App Engine 任务队列创建任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21976122/