按需n秒后执行云功能 [英] Executing cloud functions after n seconds on demand

查看:38
本文介绍了按需n秒后执行云功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中我必须向用户发送有关某项工作的通知,并且用户必须在1分钟内接受该工作,如果他没有接受,则该工作的请求应发送给下一个用户.

I am working on an application where I have to send notification to the users regarding some job, and user has to accept the job within 1 minute, if he doesn't, the job's request should be sent to the next user.

我正在使用Firestore作为数据库.创建作业时,触发器将向已分配的用户发送通知.现在,我必须等待60秒钟,以确认用户是否已接受该作业并开始执行该过程,否则,我必须将该作业分配给新用户.

I am using firestore as a database. When I create a job, trigger will send notification to the assigned user. Now I have to wait for 60 seconds to confirm if user has accepted the job and started the procedure, if not I have to assign that job to the new user.

我不确定如何创建在延迟后执行云功能的过程.

I am not sure how I can create such procedure where cloud functions are executed post delayed.

示例:第一次执行将由触发器完成,并在60秒后命令第二次执行.第二次执行检查作业是否被接受,如果终止,则将终止并且不要求后期延迟执行;如果不接受作业,它将重复第一次执行的过程,并在60秒后请求第三次执行.

Example: First execution will be done by trigger, and it will order for second execution after 60 seconds. Second execution checks if job is accepted, if so it will terminate and demands no post delayed execution, if job is not accepted, it will repeat the procedure of first execution and request for third execution after 60 seconds.

Google云中有哪些可用资源可实现这一目标?

What are the available resources in google cloud to achieve this?

谢谢

推荐答案

您可以使用云任务安排延迟回叫到Cloud Function的呼叫.

You can use Cloud Tasks to schedule a delayed call back to a Cloud Function.

这篇关于按需n秒后执行云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆