lib/emittance/resque/dispatcher.rb in emittance-resque-1.0.0 vs lib/emittance/resque/dispatcher.rb in emittance-resque-1.1.0
- old
+ new
@@ -6,11 +6,11 @@
module Resque
class Dispatcher < Emittance::Dispatcher; end
end
end
-require 'emittance/resque/process_event_job'
+require 'emittance/resque/event_fanout_job'
require 'emittance/resque/event_serializer'
require 'emittance/resque/event_serializer/default'
module Emittance
module Resque
@@ -18,11 +18,11 @@
# The Resque dispatcher for Emittance.
#
class Dispatcher
MethodCallRegistration = Struct.new(:klass_name, :method_name, :queue)
- PROCESS_EVENT_JOB = Emittance::Resque::ProcessEventJob
+ EVENT_FANOUT_JOB = Emittance::Resque::EventFanoutJob
DEFAULT_QUEUE = :default
class << self
include Emittance::Helpers::ConstantHelpers
@@ -33,14 +33,13 @@
end
private
def _process_event(event)
- registrations = registrations_for(event.class)
serialized_event = serialize_event(event)
- registrations.each { |registration| enqueue_job registration, serialized_event }
+ enqueue_fanout_job(serialized_event)
end
def _register(_identifier, _params = {}, &_callback)
raise InvalidCallbackError, 'Emittance::Resque cannot accept closures as callbacks at this time'
end
@@ -55,17 +54,11 @@
queue = params[:queue]
MethodCallRegistration.new(object.name, method_name, queue)
end
- def enqueue_job(registration, event)
- queue = queue_from_registration(registration)
-
- ::Resque.enqueue_to queue, PROCESS_EVENT_JOB, registration.klass_name, registration.method_name, event
- end
-
- def queue_from_registration(registration)
- registration.queue || default_queue
+ def enqueue_fanout_job(event)
+ ::Resque.enqueue EVENT_FANOUT_JOB, event
end
def serialize_event(event)
Emittance::Resque::EventSerializer.serialize event
end