brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.65k stars 114 forks source link

Implement wait feature for Rails ActiveJob #97

Closed brandonhilkert closed 9 years ago

brandonhilkert commented 9 years ago

Currently, ActiveJob allows you to enqueue a job using an options has with keys wait and wait_until:

Sucker Punch currently allows this using the following syntax: https://github.com/brandonhilkert/sucker_punch#perform-in

To have this functionality in the ActiveJob adapter, the enqueue_at method needs to be implemented. Here is Sidekiq's: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb#L27

It should be implemented here: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb#L26

brandonhilkert commented 9 years ago

Change here: https://github.com/brandonhilkert/rails/commit/972ede1687e5570dc8a955f87234dce9ead9f0d0

Can ya'll try this branch for Rails: https://github.com/brandonhilkert/rails/tree/suckerpunch-enqueue_at

cc: @davidcpell, @kinnrot, @kevinjalbert

kevinjalbert commented 9 years ago

@brandonhilkert I tested it via a monkey patch and it works. Couldn't swap your branch due to rails v5 dependency conflicts.

brandonhilkert commented 9 years ago

@kevinjalbert Perfect. That should be enough. Thanks!

brandonhilkert commented 9 years ago

Sadly it doesn't appear to be something they want.

https://github.com/rails/rails/pull/18726

ngelx commented 9 years ago

Hey @brandonhilkert, there is any way to walkthrough this? It is a really nice (and needed for us) feature.

brandonhilkert commented 9 years ago

@ngelx what do you mean, walkthrough?

ngelx commented 9 years ago

Sorry @brandonhilkert, there is any way we could use ActiveJob deliver_later i.e. ( MailerX.send_x(some_params).deliver_later( wait: 1.hour) ) or how we could implement something similar?. We are planing to use sucker_punch for testing on heroku, and keeping low cost is necessary for the project.

Thanks in advance.

brandonhilkert commented 9 years ago

@ngelx The feature is available by just using the gem itself: https://github.com/brandonhilkert/sucker_punch#perform-in

ActiveJob doesn't really get you anything unless you plan to switch processing libraries frequently.