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

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.

Related

Is it possible to have a multi-endpoint REST API on Google Cloud Functions? (Aws Lambda migration to GCF)

My company has been using AWS Lambda for many years to run our Spring Boot REST API. We are migrating to GCP and they want me to deploy our code to GCF the same way we were with AWS Lambda, but I am not sure that GCF works that way.
According to Google Cloud Functions are only good for Single Endpoints and can only work as a web server using the functions framework.
Spring has a document that uses the GcfJarLauncher, but that is still in alpha and I can only get it to work for a single endpoint. Any additional functions I put into the code are ignored and every endpoint triggers the same function.
There were some posts here on SO that talked about using Functional Beans to map to multiple functions, but I couldn't fully get it working and my boss isn't interested in that.
I've also read of people putting the endpoint in the request payload and then mapping to the proper function, but we are not interested in doing that either.
TLDR/Conclusion:
Is it even possible to deploy our app to GCF or do we need to use Cloud Run (as Google suggests in my first link)?

Does MassTransit support Activity / ConsolidationId on Azure?

I'm using Application Insights (AI) to instrument my code. AI uses Activity to provide some data. Activity.ParentId can be used as a per-transaction identifier, across multiple services, so that a single API call can be tracked through the code, to the database and other HTTP services etc.
MassTransit has a message ConsolidationId, to track (I believe) Sagas, but I don't think it is using the Activity.ParentId.
Am I right?
How can I get MT to use the Activity.ParentId as a ConsolidationId, both as a publisher and consumer?
MassTransit supports Open Telemetry, which can easily be configured to push data to Azure Application Insights.
There is a complete sample that shows how to configure it.

Whenever tableau sends a data driven alert, I want to trigger an external API call

I am using Tableau Servers data driven alerts. Whenever our alerts threshold is passed, we send an email to users. However, I also want to call an external API from my application (not in tableau).
I have considered trying to use AWS SNS to trigger a lambda but was hoping to see if anyone else has faced a similar use case? It does not seem like Tableaus Rest APIs provide enough metadata to handle this use case for data driven alerts

Using Azure Event Grid for event-based communication between microservices

I'm looking to implement a event-based communication pattern between my microservices and I'm looking to use Azure Service Bus to handle the messaging. In the examples I've seen so far (e.g. Microsoft's eShopOnContainers) the events are handled by a common library that handles the event subscription/publishing. I'm wondering if the common library could be replaced with Azure's Event Grid service (I realise this could generate an opinion-based answer, so please remove this question if it is deemed so)?
I like how Event Grid has retry capabilities, receives events from Azure Service Bus, push-like functionality (meaning my microservice doesn't need to poll), as well as other features, so in my mind it seems like a good fit. However, I'm fairly new to the event-based communication concept so I'm well aware I could be missing something.
If Azure Event Grid could be used to handle the events, is it possible to send the event to a Web Api endpoint? Once again, the examples I've seen so far all send the event to a Azure Function trigger, but I'm not planning on using any Azure Functions for my microservices.
If anyone had any examples they could point me to where Azure Service Bus and Event Grid were used for communication between microservices, that would be appreciated.

Deploy Hubot on AWS Lambda?

I'm a noob using Hubot, so please bear with me.
I was going through Hubot's documentation ( https://hubot.github.com/docs/deploying/ ) and saw that we can deploy to Heroku, Unix systems and others.
May I know how can Hubot be deployed on AWS Lambda ?
Best Regards.
I was wondering the same thing. I think the answer is probably "yes, if your chat system can send you http when traffic happens". I think Lambda is probably a great choice, since each message in chat is an event to process according to the rules that your bot has. So, the Lambda function invocation model is a good fit - lots of tiny invokes. You might, though, want to filter the traffic that gets to the function, though, if your chat system is high-traffic.
For example Slack's Events API lets you subscribe to all of the things you might need the bot to see, I think. You'd then need to route those requests to your lambda function, which you could do via AWS API Gateway.
The existing hubot-slack adapter uses the Real-Time Messaging API, though, so you'd need to write your own adaptor for the Events API http that the API Gateway receives.
The same approach (and requirement) applies to other chat systems.

Resources