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')


67
68
69
# File 'lib/backburner/performable.rb', line 67

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



73
74
75
# File 'lib/backburner/performable.rb', line 73

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

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/backburner/performable.rb', line 5

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