触发远程settimeout云功能请求

发布于 2025-02-13 12:11:55 字数 471 浏览 1 评论 0原文

我正在使用firebase,无论使用httprequest云函数(连接错误,选项卡或浏览器封闭)),想更新一个值。

我想到了一个Settimeout,但这并不能解决问题,好像发生任何事情一样,请求将失败,因为它与客户端有关。

然后我的想法是在远程服务器上发送请求(有点像CRON作业),该请求应在一定的延迟(假设30分钟)上执行,但这将取消队列中的先前请求(基于用户ID和请求路径)

我怎么能实现这一目标?

示例:

request number 1 -> www.myrequest with { userUID:1, data:{size:1}}
request time:12:01
request number 2 -> www.myrequest with { userUID:1, data:{size:30}}
request time:12:02

请求2取消请求1并在30分钟后执行

I'm using firebase and would like to update a value no matter what happens using a HttpRequest Cloud function ( connection error, tab or browser closed ).

I thought of a setTimeout but this doesn't solve the issue as if anything happens the request will fail as it is related to client side.

Then my idea was to send the request on a remote server ( a bit like a cron job ) that should perform at a certain delay ( let's say 30 minutes ) but that would cancel the previous request in queue ( based on userID and request path )

How could I achieve that and is this possible?

example:

request number 1 -> www.myrequest with { userUID:1, data:{size:1}}
request time:12:01
request number 2 -> www.myrequest with { userUID:1, data:{size:30}}
request time:12:02

request 2 cancels request 1 and gets executed 30 minutes later

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文