How to schedule repeated jobs or tasks from user parameters in Google App Engine?

前端 未结 2 2050
猫巷女王i
猫巷女王i 2020-12-19 20:00

I\'m using Google App Engine and I want like to be able to schedule jobs based users\' parameters.

I know this can be done with cron jobs, but looks like it does not

相关标签:
2条回答
  • 2020-12-19 20:38

    You may want to star Issue 3638: Cron jobs to be scheduled programatically

    Meanwhile you can write your own implementation: have a generic cron job running periodically (every 1 minute being the finest resolution) and inside that cron job check user-programmed scheduling data persisted somewhere (in the datastore for example) and, if needed, trigger execution of whatever is needed to be executed, either inlined or by enqueueing a task in some task queue.

    It's possible to drive the scheduling resolution even under 1 minute, if needed, see High frequency data refresh with Google App Engine

    0 讨论(0)
  • For my debts tracking app DebtsTracker.io I've implemented it manually.

    When a user creates a debt record he can specify due date that is stored in an unindexed DueDate and indexed ReminderDateTime fields.

    I have a cron that query records with ReminderDateTime < today and sends notifications. Once notification sent the ReminderDateTime is set to null or far future so it's not picked in next cron run. If user hits Remind me again I am updating the ReminderDateTime to some date in future (user decides when).

    If ReminderDateTime is closer then cron interval then I simply create I put a task to queue with appropriate delay.

    This works very well and is very cheap to run.

    0 讨论(0)
提交回复
热议问题