问题
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