cloudtasker icon indicating copy to clipboard operation
cloudtasker copied to clipboard

Support cron scheduling via GCP Cloud Scheduler

Open alachaum opened this issue 4 years ago • 8 comments

Currently cron jobs are managed using Cloud Tasks and Redis. Investigate a way to also support Cloud Scheduler to eliminate the dependency on Redis.

alachaum avatar Jan 14 '21 09:01 alachaum

Is it already worked one? If not, I can take a look at this one. I guess the starting point would be here https://github.com/keypup-io/cloudtasker/blob/master/lib/cloudtasker/cron/schedule.rb.

Fodoj avatar Jan 16 '21 15:01 Fodoj

@Fodoj not it's not worked on yet. Feel free to give it a try! 😄

You can create a new module called CloudScheduler (instead of cron). The implementation should be relatively straightforward but there isn't much doc about the shape of the Cloud Scheduler webhooks. So you'll have to experiment via ngrok.

Cloud Scheduler does support unique names for jobs. It should therefore be possible to lookup / create if missing, same as the cron extension (see: https://github.com/keypup-io/cloudtasker/blob/master/lib/cloudtasker/cron/schedule.rb#L55)

Also, considering names must be truly unique in Cloud Scheduler, I recommend prefixing the schedule names with the gcp_queue_prefix (see https://github.com/keypup-io/cloudtasker/blob/master/lib/cloudtasker/config.rb#L188)

Let me know if you get stuck anywhere, I'm happy to help.

alachaum avatar Jan 22 '21 10:01 alachaum

I'm not promising anything... but here I go :)

vovimayhem avatar Sep 10 '21 02:09 vovimayhem

Hello all. First off, thank you for developing this gem - it's absolutely fantastic! I'm using this with ActiveJob in my current project.

Second, I'm wondering if there's any updates on this? I can definitely see a need for this in the future. I understand there is no way currently to implement cron + ActiveJob + cloudtasker? Similarly for job locks/uniqueness? Again, thank you for all the effort!

matthewtory avatar Jan 11 '22 00:01 matthewtory

@matthewtory thanks a lot! I'm glad you like it 😊

There is still no way to support GCP cloud scheduler. This is next on my list after addressing #11

In the meantime you can make a small exception and use a native cloudtasker job for cron jobs (unless you use different backends for dev vs production)

Note that even if I add support for GCP Scheduler, I'm not sure how much it will be compatible with ActiveJob. ActiveJob has a minimal API due to the fact it must keep a consistent interface for many libraries.

alachaum avatar Jan 24 '22 14:01 alachaum

Is this still going to be added? I see @ceritium worked on it but there hasn't been any updates on that PR in the last 6 months.

MohamedBeydoun avatar Jan 24 '24 20:01 MohamedBeydoun

Is this still going to be added? I see @ceritium worked on it but there hasn't been any updates on that PR in the last 6 months.

Hi @MohamedBeydoun, please take a look at my last comment on the PR.

ceritium avatar Jan 25 '24 08:01 ceritium

Is this still going to be added? I see @ceritium worked on it but there hasn't been any updates on that PR in the last 6 months.

Hi @MohamedBeydoun, please take a look at my last comment on the PR.

Thanks!

MohamedBeydoun avatar Jan 25 '24 17:01 MohamedBeydoun