lib/rising_dragon/sqs/worker.rb in rising_dragon-0.1.0 vs lib/rising_dragon/sqs/worker.rb in rising_dragon-0.1.1
- old
+ new
@@ -1,7 +1,5 @@
-require 'shoryuken'
-
module RisingDragon
module SQS
module Worker
def self.included(base)
base.class_eval do
@@ -9,23 +7,26 @@
end
base.extend(ClassMethods)
end
module ClassMethods
- def rising_dragon_options(opt = {})
- shoryuken_options(opt)
+ def rising_dragon_options(sqs_queue_name, weight, group, opt = {})
+ shoryuken_opt = { queue: sqs_queue_name, body_parser: :json }.merge(opt)
+ shoryuken_options(shoryuken_opt)
+
+ Shoryuken.add_queue(sqs_queue_name, weight, group)
end
- def register_handlers(_emitter)
- raise 'Overwrite self.register_handlers'
+ def rising_dragon_register(event_name, handle_class)
+ emitter.register(event_name, handle_class)
end
- def emitter
- return @emitter if @emitter
+ def rising_dragon_ignore(event_name)
+ emitter.ignore(event_name)
+ end
- @emitter = ::RisingDragon::SQS::Emitter.new
- register_handlers(@emitter)
- @emitter
+ def emitter
+ @emitter ||= ::RisingDragon::SQS::Emitter.new
end
end
def perform(_sqs_msg, body)
self.class.emitter.emit_sns_msg(body)