Our startup is "cloud-native" using Firebase and Google Cloud. We are looking into going into event-driven design, but I have a hard time matching the concept to the specific services on Firebase or GCP.
An example: A user creates a contract draft (a Firestore Document) via a mobile app. We need to trigger the following operations:
We managed to put those actions into Cloud Function triggers so far, but our trigger code has become messy, and in rare cases, the operations run above the Cloud Function thresholds (2GB and 9 minutes).
Our plan to improve the code base and reduce trigger-based operations:
I've investigated Pub/Sub but thought it would be an overkill, since we don't have to deal too much with services outside of GCP, and our scale does not need it atm. Can we achieve the above within the realm of Firebase tools?
Pubsub is actually exactly what you need. It's not overkill - it's a common and preferred solution in Google Cloud to handle subscriptions to events. In fact, Cloud Functions is already built on top of pubsub.
The Firebase tools actually provide their own interface for deploying pubsub Cloud Functions. You can read about that in the documentation. However, if you need more computing power than provided by Cloud Functions, Firebase products will not help you, and you will need to look into Google Cloud products like Compute Engine. You will still likely use pubsub to notify your chosen backend.
Since the scale is not an issue for you at the moment, you can achieve these using the Firebase tools.
If you did not read already the Cloud Firestore triggers documentation would be a good read in order to understand how to improve and make them more future proof in case of different events.
Also, it would be worth checking this documentation and look into Observables if you want to create subscriptions with services that would look for certain actions to be executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With