Module: Qwirk::Worker::ClassMethods
- Defined in:
- lib/qwirk/worker.rb
Instance Method Summary collapse
-
#default_fail_queue_target ⇒ Object
Defines the default value of the fail_queue_target.
-
#fail_queue(target, opts = {}) ⇒ Object
Set the fail_queue target => boolean true - exceptions in the worker will cause the message to be forwarded to the queue of <default-name>Fail For instance, an Exception in FooWorker#perform will forward the message to the queue FooFail false - exceptions will not result in the message being forwarded to a fail queue string - equivalent to true but the string defines the name of the fail queue.
- #fail_queue_name(worker_config) ⇒ Object
- #fail_queue_target ⇒ Object
- #queue(name, opts = {}) ⇒ Object
- #queue_name(default_name) ⇒ Object
- #queue_options ⇒ Object
- #topic(name, options = {}) ⇒ Object
- #topic_name ⇒ Object
Instance Method Details
#default_fail_queue_target ⇒ Object
Defines the default value of the fail_queue_target. For extenders of this class, the default will be true but extenders can change this (ReplyWorker returns exceptions to the caller so it defaults to false).
75 76 77 |
# File 'lib/qwirk/worker.rb', line 75 def default_fail_queue_target true end |
#fail_queue(target, opts = {}) ⇒ Object
Set the fail_queue target =>
boolean
true - exceptions in the worker will cause the message to be forwarded to the queue of <default-name>Fail
For instance, an Exception in FooWorker#perform will forward the message to the queue FooFail
false - exceptions will not result in the message being forwarded to a fail queue
string - equivalent to true but the string defines the name of the fail queue
65 66 67 |
# File 'lib/qwirk/worker.rb', line 65 def fail_queue(target, opts={}) @fail_queue_target = target end |
#fail_queue_name(worker_config) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/qwirk/worker.rb', line 93 def fail_queue_name(worker_config) # TBD - Set up fail_queue as a config target = self.class.fail_queue_target # Don't overwrite if the user set to false, only if it was never set target = self.class.default_fail_queue_target if target.nil? if target == true return Qwirk.fail_queue_name(config.name) elsif target == false return nil elsif target.kind_of?(String) return target else raise "Invalid fail queue: #{target}" end end |
#fail_queue_target ⇒ Object
69 70 71 |
# File 'lib/qwirk/worker.rb', line 69 def fail_queue_target @fail_queue_target end |
#queue(name, opts = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/qwirk/worker.rb', line 43 def queue(name, opts={}) # If we're using the default name but we still want to set queue options, then a name won't be given. if name.kind_of?(Hash) @queue_options = name else @queue_name = name.to_s @queue_options = opts end end |
#queue_name(default_name) ⇒ Object
79 80 81 82 83 |
# File 'lib/qwirk/worker.rb', line 79 def queue_name(default_name) return @queue_name if @queue_name return nil if @topic_name return default_name end |
#queue_options ⇒ Object
89 90 91 |
# File 'lib/qwirk/worker.rb', line 89 def @queue_options ||= {} end |
#topic(name, options = {}) ⇒ Object
53 54 55 56 |
# File 'lib/qwirk/worker.rb', line 53 def topic(name, ={}) @topic_name = name.to_s @queue_options = end |
#topic_name ⇒ Object
85 86 87 |
# File 'lib/qwirk/worker.rb', line 85 def topic_name @topic_name end |