如何为连续的数据流提供连续的firebase云功能?

问题描述 投票:0回答:2

我需要使用Twitter Stream API将推文数据流式传输到我的firebase云功能,如下所示:

client.stream('statuses/filter', params,  stream => {

  stream.on('data', tweet => {
    console.log(tweet);
  })

  stream.on('error', error => {
    console.log(error)
  })

})

流是连续的,但火山云功能在一段时间后关闭。我可以使用什么解决方案来连续接收流数据?

firebase twitter google-cloud-functions twitter-streaming-api
2个回答
2
投票

云功能的最大运行时间为540秒as documented。您可能需要查看可能使用Compute Engine Instance from Google Cloud,您可以在其中运行无限制的代码。或者你可以看看使用Google Cloud Scheduler每x次运行你的函数来获取新的推文。


0
投票

接受的回应表明运行GCE并且肯定是正确的,我想指出任何对云功能感兴趣的人 - 无服务器解决方案 - 可能会发现GAE(App Engine)对于流数据更加可行。

我们的应用程序利用App Engine Standard作为提取服务,它的工作方式就像GCE要求的消除技术。如果您的应用程序需要高级网络功能App Engine Flexible或GKE(Kubernetes Engine)也可能需要关注!

© www.soinside.com 2019 - 2024. All rights reserved.