Module: Backburner::Performable

Defined in:
lib/backburner/performable.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.handle_asynchronously(klass, method, opts = {}) ⇒ Object

Make all calls to an instance method asynchronous. The given opts will be passed to the async method. NB: The method called on the async proxy will be “”#method_without_async“. This will also be what’s given to the Worker.enqueue method so your workers need to know about that. It shouldn’t be a problem unless the producer and consumer are from different codebases (or anywhere they don’t both call the handle_asynchronously method when booting up)

Examples:

Backburner::Performable.handle_asynchronously(MyObject, :long_task, queue: 'long-tasks')


65
66
67
# File 'lib/backburner/performable.rb', line 65

def self.handle_asynchronously(klass, method, opts={})
  _handle_asynchronously(klass, klass, method, opts)
end

.handle_static_asynchronously(klass, method, opts = {}) ⇒ Object

Make all calls to a class method asynchronous. The given opts will be passed to the async method. Please see the NB on #handle_asynchronously



71
72
73
# File 'lib/backburner/performable.rb', line 71

def self.handle_static_asynchronously(klass, method, opts={})
  _handle_asynchronously(klass, klass.singleton_class, method, opts)
end

.included(base) ⇒ Object



3
4
5
6
7
# File 'lib/backburner/performable.rb', line 3

def self.included(base)
  base.send(:include, InstanceMethods)
  base.send(:include, Backburner::Queue)
  base.extend ClassMethods
end