Class: Workerholic::WorkerBalancer
- Inherits:
-
Object
- Object
- Workerholic::WorkerBalancer
- Defined in:
- lib/workerholic/worker_balancer.rb
Instance Attribute Summary collapse
-
#alive ⇒ Object
readonly
Returns the value of attribute alive.
-
#auto ⇒ Object
readonly
Returns the value of attribute auto.
-
#queues ⇒ Object
Returns the value of attribute queues.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ WorkerBalancer
constructor
A new instance of WorkerBalancer.
- #kill ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ WorkerBalancer
Returns a new instance of WorkerBalancer.
6 7 8 9 10 11 12 13 |
# File 'lib/workerholic/worker_balancer.rb', line 6 def initialize(opts = {}) @storage = Storage::RedisWrapper.new @queues = fetch_queues @workers = opts[:workers] || [] @alive = true @logger = LogManager.new @auto = opts[:auto_balance] end |
Instance Attribute Details
#alive ⇒ Object (readonly)
Returns the value of attribute alive.
3 4 5 |
# File 'lib/workerholic/worker_balancer.rb', line 3 def alive @alive end |
#auto ⇒ Object (readonly)
Returns the value of attribute auto.
3 4 5 |
# File 'lib/workerholic/worker_balancer.rb', line 3 def auto @auto end |
#queues ⇒ Object
Returns the value of attribute queues.
4 5 6 |
# File 'lib/workerholic/worker_balancer.rb', line 4 def queues @queues end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/workerholic/worker_balancer.rb', line 3 def storage @storage end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
3 4 5 |
# File 'lib/workerholic/worker_balancer.rb', line 3 def thread @thread end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
3 4 5 |
# File 'lib/workerholic/worker_balancer.rb', line 3 def workers @workers end |
Instance Method Details
#kill ⇒ Object
23 24 25 |
# File 'lib/workerholic/worker_balancer.rb', line 23 def kill thread.kill end |
#start ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/workerholic/worker_balancer.rb', line 15 def start if auto auto_balance_workers else evenly_balance_workers end end |