如何让 WebSockets 连接到 Google Cloud Function? [英] How can I have WebSockets connect to a Google Cloud Function?
问题描述
我有一个正在订阅的 WebSocket,当有事件发生时,我想触发一个 Google Cloud 函数.这可能吗?
例如,我正在收听
所以这里有一些代码监听 Web 套接字,然后通过 Pub/Sub 或其他支持的触发器类型之一触发 Cloud Functions.
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
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.
这篇关于如何让 WebSockets 连接到 Google Cloud Function?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!