Is there a way to deploy a firebase function other than firebase deploy --only functions?
I'm looking for a way to have a user build and deploy a pubsub function client-side.
Example
User adds a weather stations to their account. User selects time interval to ping weather station and record weather data and then deploys this function to run each time interval to catalog the weather data.
Currently, I have to make individual firebase functions for each user, but I'm wondering if there is a way that a user can generate and deploy a function on their own.
CodePudding user response:
To deploy Cloud Functions one has to be a collaborator on the Firebase/GCP project, which is not a feasible solution when you want user-specific Cloud Functions.
A common approach here is to have one (typically callable) Cloud Function that your app calls when the user adds a weather station to their account. In that function you then set up a Cloud Functions trigger through Cloud Tasks, to run at the schedule for that weather station.
For more on this and other options, see:
- Doug's blog post: How to schedule a Cloud Function to run in the future with Cloud Tasks (to build a Firestore document TTL)
- How to trigger cloud function based on date stored in cloud firestore?
- Is there any TTL (Time To Live ) for Documents in Firebase Firestore, which explains the other common option of running at a fixed, regular interval (like very minute)
- Cloud Functions - Remove Firestore documents after variable time and notify user
