brandonhilkert / sucker_punch

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

check some condition #61

Closed andreydeineko closed 10 years ago

andreydeineko commented 10 years ago

Hello all,

not sure, if it is an issue, because I did not experience a problem yet.. But still. I wonder, if sucker_punch is a tool corresponding to my need.

I want to check if an object's attribute was changed within 24 hours after creation, and if yes - send an email notification. The problem is to set this checking not once, but periodically (say, every 15 minutes).

I have deployed my app on Heroku and know about their solutions, but currently i seek for free of charge solution.

Thank you in advance!

brandonhilkert commented 10 years ago

Removing the interest for a free solution, how would you have done it without sucker punch?

On Wednesday, June 18, 2014, Andrey Deineko notifications@github.com wrote:

Hello all,

not sure, if it is an issue, because I did not experience a problem yet.. But still. I wonder, if sucker_punch is a tool corresponding to my need.

I want to check if an object's attribute was changed within 24 hours after creation, and if yes - send an email notification. The problem is to set this checking not once, but periodically (say, every 15 minutes).

I have deployed my app on Heroku and know about their solutions, but currently i seek for free of charge solution.

Thank you in advance!

— Reply to this email directly or view it on GitHub https://github.com/brandonhilkert/sucker_punch/issues/61.


_The Build a Ruby Gem guide is available! http://brandonhilkert.com/books/build-a-ruby-gem/?utm_source=gmail-sig&utm_medium=email&utm_campaign=gem-config_

http://brandonhilkert.com

andreydeineko commented 10 years ago

These asynchronous tasks and delayed jobs are totally new things for me, so I do not know, truly to say how it should be done. From what I've read, there is a Heroku Scheduler, which is free for adding to app, but then they charge you for every hour using it..

Any chance you can provide me with some help accomplishing this task with sucker_punch?

brandonhilkert commented 10 years ago

Gotcha. So the heroku scheduler allows you to run Cron-style tasks. If your job is real quick, the charges would be minimal. This is how I would do it. Sucker Punch isn't necessary in this context.

andreydeineko commented 10 years ago

Yea, probably the job is quick - checking if submission.created_at <= (Time.now -(24_60_60)). Ok then, thanks for instantaneous replies!

Good luck!

lulalala commented 6 years ago

Having a similar need here, I need to do some web crawling periodically.

I don't use Heroku, so I am thinking of a pure SuckerPunch solution.

I think this would work:

class FooJob
  include SuckerPunch::Job

  def perform(event)
    # Do things
    FooJob.perform_in(60 * 50)
  end
end