Google云端函数:在特定时间编辑Firebase节点 [英] Google Cloud Functions: edit Firebase node at a specific time

查看:135
本文介绍了Google云端函数:在特定时间编辑Firebase节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的Firebase数据库中的兴趣领域如下所示:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b - <自动生成的push()id>
- requestValid:
- requestExpiry
--epochSecond:
--nano:

requestValid是0/1。 requestExpiry与Java Instant一起存储。 requestExpiry将在未来几个小时。现在我想requestExpiry时间发生时设置requestValid为0。有人建议我Google云端函数可以帮助我。但是我怎么看不到?一旦requestExpiry已经通过,我的函数将如何继续等待并自动触发?如果您可以使用GCF显示正确的方法,或者您可以建议更简单的方法,那么这将非常有帮助。



谢谢!

解决方案

目前没有办法让函数等待任意长的时间。功能将在配置的超时(最长9分钟)后终止。而且,目前还没有办法在一定的延迟之后安排一个功能的执行。您需要使用其他后端组件来编写一些内容,以长时间轮询更改的值,并根据需要进行响应。

这是一个常见的请求内置的函数调度机制,而云功能团队正在研究这一点。


So the area of interest in my Firebase database is as follows:

root  
  -requests  
     - <Autogenerated push() id>  
          - requestValid:  
          - requestExpiry  
                -epochSecond:  
                -nano:

requestValid is 0/1. requestExpiry is stored with Java Instant. The requestExpiry is some hours ahead in future. Now I'd like to set requestValid to 0 when the requestExpiry time occurs.

Someone suggested me that Google Cloud Functions could help me with that. But I can't see how? How would my function keep waiting and auto-fire once requestExpiry has passed? It'll be very helpful if you could show the right approach using GCF, or any easier alternative you can suggest?

Thanks!

解决方案

There's currently no way to keep a function waiting for an arbitrarily long amount of time. Functions will be terminated after their configured timeout (9 minutes max). Also, there is currently no way to schedule the execution of a function after some delay. You'd need to write something using some other backend component to "long poll" the value for a change and react as needed.

It's a common request to have some sort of built-in scheduling mechanism for functions, and the Cloud Functions team is looking into that.

这篇关于Google云端函数:在特定时间编辑Firebase节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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