google App Engine cron 作业可以触发后台云功能吗?

Can google app engine cron jobs trigger a background cloud function?

阅读文档后:https://cloud.google.com/appengine/docs/standard/nodejs/scheduling-jobs-with-cron-yaml

好像cron jobs只支持HTTP云功能

我想用GAEcron jobsgoogle pubsub每小时触发我的后台云功能。喜欢:

GAE corn jobs => Cloud pub/sub => 背景 cloud function.

这可能吗?

Cron 服务未与云功能集成。它是应用引擎的一部分。

您不能直接从 Cron 作业调用 Cloud Functions,因为它是 App Engine service,但您可以从 Cron 作业调用 App Engine 处理程序,并让该处理程序调用您的 Cloud Function,使用您想要从 Pub/Sub 中使用的任何信息。

有个例子here,基本上就是我说的。您可以将其替换为在 App Engine 中使用 Node.js 而不是 Python:

const express = require('express');

const app = express();

app.get('/', (req, res) => {
  const request = require('request');

  request('YOUR_FUNCTION_URL', { json: false }, (err, res, body) => {
    if (err) {
      return console.log(err);
    }
    res
      .status(200)
      .send('Trigger called')
      .end();
  });
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

编辑:

Cloud Scheduler is a new service (as of right now in beta) which can create cron jobs that target either App Engine, Pub/Sub or URL's. In your case, you can set up one job hitting the URL of your function, as mentioned in here。就简单多了。

有可能,详细描述here