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:
- Notify other users that are parties in the contract via email and push notification
- Write to the notifications table so that the user could have an "inbox" in the app and mark them read or deleted
- Generate a job that will poll the contract in a month, and if it does not change state, delete the contract
- Run a series of calculations on the server
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:
- A user is creating a contract (Cloud Firestore)
- The Cloud Firestore trigger creates an event (Cloud Functions)
- Services that need to do something about it subscribe to the event stream and execute appropriate actions. (What comes here?)
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?