How can I have WebSockets connect to a Google Cloud Function?

白昼怎懂夜的黑 提交于 2021-02-05 07:12:05

问题


I have a WebSocket that I'm subscribing to and when an event comes in, I want to trigger a Google Cloud Function. Is this possible?

For example, I'm listening to https://alpaca.markets/docs/api-documentation/api-v2/streaming/

And whenever I get trade_updates, I want to run a function on Google cloud Functions


回答1:


All trigger types for Cloud Functions are listed here: https://cloud.google.com/functions/docs/calling

Web Sockets are not directly supported as a trigger type.

The closest I can think of is setting up an architecture like this:

So here you have some code listening to the web socket and then triggering Cloud Functions through Pub/Sub or one of the other supported trigger types.



来源:https://stackoverflow.com/questions/62174191/how-can-i-have-websockets-connect-to-a-google-cloud-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!