Adriaan Meuris
Adriaan Meuris

Reputation: 391

How to reschedule a task with Google Cloud Tasks

I'm implementing a feature to send an email to customers 24 hours after they uninstall our application. This is done by triggering a HTTP endpoint via Google Cloud Tasks, which checks if the application remains uninstalled before sending the email. The challenge arises as customers might reinstall and uninstall the application within this period. I aim to:

My current implementation with Google Cloud Tasks handles de-duplication effectively, preventing multiple emails by disallowing task creation with duplicate IDs. However, I'm encountering limitations with rescheduling or postponing tasks because:

Given these constraints, how can I manage to have a task execute only once, 24 hours after the latest uninstall event, especially considering multiple uninstall/reinstall events can happen within the 24-hour timeframe?

Upvotes: 0

Views: 169

Answers (1)

niyi
niyi

Reputation: 319

If you have a database, you can store the task id after uninstall and when the same user reinstalls, delete the pending task and clear the task id. Rinse and repeat.

If you do not have a database, you need a way to uniquely identify the user. You can use this unique user id as the task id plus an increment integer. Then, when a user installs, check the task list for task with user id as suffix.

Upvotes: 0

Related Questions