Sidekiq? How?
Closed this issue · 2 comments
The README says "SMSEasy works perfectly well with background job processing gems such as Sidekiq and delayed_job." But how?
An example on Sidekiq's Delayed Extensions makes me think I should do something like:
sms_sender = SMSEasy::Client.new
sms_sender.delay_until(10.seconds.from_now).deliver('18005551212', 'att, 'Hello world!')
But this results in undefined method 'delay_until' for #<SMSEasy::Client:0x007fcdf42f5598>
.
Basically, I've tried every combination of cramming delay_until()
wherever I thought I could, but I must be misunderstanding how to queue an SMSeasy delivery.
I should note that I'm a n00b when it comes to Sidekiq. I've been able to use delay_until()
for ActionMailer just fine, though.
It never fails. On the rare occasion I can't figure something out, then post an issue, I promptly figure it out.
I had to create a worker:
class DelayedSmsWorker
include Sidekiq::Worker
def perform(number, carrier, message, options={})
sms_sender = SMSEasy::Client.new
sms_sender.deliver(number, carrier, message, options)
end
end
Then use this in my controller:
DelayedSmsWorker.perform_at(10.seconds.from_now, '18005551212', 'att', 'Hello world!')
Worked like a charm.
Glad you got it figured out! :)