Skip to content

Instantly share code, notes, and snippets.

@owenr
Created July 10, 2015 01:17
Show Gist options
  • Save owenr/b5d9e19b0fa2cda361c6 to your computer and use it in GitHub Desktop.
Save owenr/b5d9e19b0fa2cda361c6 to your computer and use it in GitHub Desktop.
ActiveJob adapter for TorqueBox 4.0 scheduler (torquebox-scheduling). Seems to work; place into config/initializers/ and specify the adapter in config/application.rb as follows: config.active_job.queue_adapter = :torquebox_scheduler
require 'torquebox-scheduling'
module ActiveJob
module QueueAdapters
class TorqueboxSchedulerAdapter
class << self
def enqueue(job) #:nodoc:
TorqueBox::Scheduling::Scheduler.schedule(job.hash, in: 35) do
Base.execute(job.serialize)
end
end
def enqueue_at(job, timestamp) #:nodoc:
TorqueBox::Scheduling::Scheduler.schedule(job.hash, at: timestamp) do
Base.execute(job.serialize)
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment