有没有一种方法可以创建Firebase实时数据库的事件监听器?

huangapple go评论99阅读模式
英文:

Is there a way to create Firebase real time database event listeners?

问题

我正在尝试将实时事件监听器集成到使用Firebase实时数据库的应用程序中。

我看到了这篇帖子(https://github.com/firebase/firebase-admin-go/issues/229),讨论了这个问题,但似乎官方SDK不会实现这个功能。

我还发现了Firebase的REST/Streaming端点(https://firebase.google.com/docs/reference/rest/database/#section-streaming),考虑使用它来集成实时监听器。

我的问题是,有没有推荐的方法来实现这个功能?(Websockets、回调、通道等)是否已经有一个库可以做到这一点,这样我就不必从头编写代码来实现这个功能了?

英文:

I am trying to integrate real time event listeners into my application that utilizes firebase realtime database.

I came across this post that discussed this but it seems that it will not be implemented in the official SDK.

I also came across the firebase REST/Streaming endpoints and was considering using this to integrate realtime listeners.

My question is, is there a recommended way to achieve this? (Websockets, callbacks, channels ect.) Is there already a library that does this so I don't have to write code from scratch to achieve this functionality?

答案1

得分: 0

Firebase的原生Web套接字协议没有文档记录。如果不使用原生SDK,你可以通过使用Hiranya在Github问题中提供的REST Streaming API来接近原生SDK的行为。我在各种项目和各种语言中都这样做过(尽管从未在Go中),这通常是一个合理的方法,尽管比原生Web套接字稍微低效,因为它需要单独的连接来读取和写入数据。

要开始使用,我建议查看以下内容:

英文:

Firebase's native web socket wire protocol is not documented. The closest you can get to the behavior of the native SDKs (outside of using those) with a public API is by using the REST Streaming API that Hiranya also linked in the Github issue. I've done this for various projects in various languages (though never in Go), and it's often a reasonable approach though slightly less efficient than the native web sockets, as it needs separate connections for reading and writing data.

To get started, I recommend checking out:

huangapple
  • 本文由 发表于 2021年10月11日 23:08:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/69528495.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定