I am using https://github.com/mperham/sidekiq gem in a rails app to schedule tasks at a specific date and time.. Ex: Send appointment reminder 10minutes before the appointment schedule time.
class TextWorker
include Sidekiq::Worker
def perform(appointer_id)
number = Usermodel.find_by_id(appointer_id).contact
Message.create(:from => email,
:to => number,
:body => 'Thank you...Your appointment is at 10/1/2015 Sun, at 12pm')
end
end
and calling it here in appointments controller:
class Appointments_controller
def create
TextWorker.delay_until(10/20/2014, 13:40).perform_async(@user_contact)
end
delay_until doesn't work with specific date/time:
Is there any other way to perform a task at a specific date/time in sideqik? if so how? please
Sidekiq is an open-source framework that provides efficient background processing for Ruby applications. It uses Redis as an in-memory data structure to store all of its job and operational data. It's important to be aware that Sidekiq by default doesn't do scheduling, it only executes jobs.
Sidekiq reads jobs from a Redis queue, using the First In First Out (FIFO) model, to process jobs.
Execution of Sidekiq in rails applicationWorker is similar to a ruby object so it is deployed to another object to handle the ruby process. Multiple Workers are executed parallelly if they perform async use during the worker call. After completing the process, it will be generated to an HTTP request.
If you build a web application you should minimize the amount of time spent responding to every user; a fast website means a happy user.
you could pass in the calculated difference in order to send what sidekiq expects
e.g. DateTime.parse("10/20/2014")-DateTime.now
so :
delay_interval = DateTime.parse("10/20/2014")-DateTime.now
TextWorker.delay_until(delay_interval).perform_async(@user_contact)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With