简体   繁体   English

预定 Firebase 功能

[英]Scheduled Firebase Functions

I want to create some scheduled cloud functions using the syntax below to define the schedule within the source code of the function:我想使用以下语法创建一些计划的云函数,以在 function 的源代码中定义计划:

exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
  console.log('This will be run every 5 minutes!');
  return null;
});

I know that according to the documentation , this cloud function automatically creates a pub/sub topic to trigger the function according to the defined schedule.我知道根据 文档,这个云 function 会根据定义的时间表自动创建一个发布/订阅主题来触发 function。 The docs warn against manually editing the pub/sub topic in the GCP console, as it could break the scheduling.文档警告不要在 GCP 控制台中手动编辑 pub/sub 主题,因为它可能会破坏调度。

What they don't mention is how one goes about removing a pub/sub topic of a function that you want to delete or update.他们没有提到的是如何删除您想要删除或更新的 function 的发布/订阅主题。

Do I need to delete the function entirely and re-deploy it with the updated schedule details?我是否需要完全删除 function 并使用更新的计划详细信息重新部署它? Will that automatically delete the associated pub/sub topic as well?这会自动删除相关的发布/订阅主题吗? What if I just re-deploy the same function with different schedule details?如果我只是重新部署具有不同计划详细信息的相同 function 怎么办?

What if I just re-deploy the same function with different schedule details?如果我只是重新部署具有不同计划详细信息的相同 function 怎么办?

The schedule will be updated in Pub/Sub as well.时间表也将在 Pub/Sub 中更新。

Will deleting the function automatically delete the associated pub/sub topic as well?删除 function 是否也会自动删除关联的发布/订阅主题?

Yes, the topic will be deleted when a function is deleted using the CLI with firebase functions:delete functionName command or the Firebase console .是的,当使用带有firebase functions:delete functionName命令或Firebase 控制台

When you deploy a Pub/Sub triggered function from GCP, you are asked to select/create a topic and similarly you'll have to delete it yourself then.当您从 GCP 部署 Pub/Sub 触发的 function 时,系统会要求您选择/创建一个主题,同样您必须自己删除它。 GCP won't delete the topic and it might be better just in case you are using the same trigger somewhere else. GCP 不会删除该主题,如果您在其他地方使用相同的触发器,它可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM