Class: TResque::Registry
- Inherits:
-
Object
- Object
- TResque::Registry
- Defined in:
- lib/tresque/registry.rb
Instance Attribute Summary collapse
-
#app_key ⇒ Object
readonly
Returns the value of attribute app_key.
Class Method Summary collapse
- .class_hash ⇒ Object
- .class_list ⇒ Object
- .default_weight ⇒ Object
- .queue(queue_name, weight = nil) ⇒ Object
- .queue_hash ⇒ Object
-
.queues ⇒ Object
called to know what queues to set.
- .weight(key) ⇒ Object
- .worker(klass) ⇒ Object
Instance Method Summary collapse
-
#initialize(app_key) ⇒ Registry
constructor
A new instance of Registry.
- #queue(name, weight = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#app_key ⇒ Object (readonly)
Returns the value of attribute app_key.
84 85 86 |
# File 'lib/tresque/registry.rb', line 84 def app_key @app_key end |
Class Method Details
.class_hash ⇒ Object
10 11 12 |
# File 'lib/tresque/registry.rb', line 10 def class_hash @class_hash ||= {} end |
.class_list ⇒ Object
18 19 20 |
# File 'lib/tresque/registry.rb', line 18 def class_list class_hash.keys end |
.default_weight ⇒ Object
6 7 8 |
# File 'lib/tresque/registry.rb', line 6 def default_weight 100 end |
.queue(queue_name, weight = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tresque/registry.rb', line 28 def queue(queue_name, weight=nil) queue_name = queue_name.to_s if weight # take higher weight if !queue_hash[queue_name] || weight > queue_hash[queue_name] queue_hash[queue_name] = weight end else queue_hash[queue_name] ||= false end end |
.queue_hash ⇒ Object
14 15 16 |
# File 'lib/tresque/registry.rb', line 14 def queue_hash @queue_hash ||= {} end |
.queues ⇒ Object
called to know what queues to set
49 50 51 52 53 |
# File 'lib/tresque/registry.rb', line 49 def queues register_classes register_bus sorted_queues end |
.weight(key) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/tresque/registry.rb', line 40 def weight(key) if !self.queue_hash[key] self.default_weight else self.queue_hash[key] end end |
.worker(klass) ⇒ Object
22 23 24 25 26 |
# File 'lib/tresque/registry.rb', line 22 def worker(klass) klass = klass.name if klass.is_a?(Class) klass = klass.to_s class_hash[klass] = 1 end |