Вот мой cron.yaml
:
cron:
- description: 'cron trigger create email'
url: /cron/events/createEmail
schedule: every 1 hours
target: cron-jobs-background-cloud-function
- description: 'cron trigger create user'
url: /cron/events/createUser
schedule: every 1 hours
target: cron-jobs-background-cloud-function
server.js
:
function taskHandler() {}
app.get('/cron/events/createEmail', (req, res) => {
const topicName = req.path.split('/').slice(-1)[0];
console.log('topicName: ', topicName);
taskHandler(topicName);
res.sendStatus(200);
});
app.get('/cron/events/createUser', (req, res) => {
const topicName = req.path.split('/').slice(-1)[0];
console.log('topicName: ', topicName);
taskHandler(topicName);
res.sendStatus(200);
});
И cron.yaml
, и server.js
, они дублируются.
Поддерживает ли cron service
шаблон пути следующим образом:
cron.yaml
cron:
- description: 'cron-jobs-background-cloud-function'
url: /cron/events/*
schedule: every 1 hours
target: cron-jobs-background-cloud-function
server.js
app.get('/cron/events/*', (req, res) => {
const topicName = req.path.split('/').slice(-1)[0];
console.log('topicName: ', topicName);
taskHandler(topicName);
res.sendStatus(200);
});