Class: Beez::Processor
- Inherits:
-
Object
- Object
- Beez::Processor
- Defined in:
- lib/beez/processor.rb
Instance Attribute Summary collapse
-
#busy_count ⇒ Object
readonly
Returns the value of attribute busy_count.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#timer ⇒ Object
readonly
Returns the value of attribute timer.
-
#worker_class ⇒ Object
readonly
Returns the value of attribute worker_class.
Instance Method Summary collapse
-
#initialize(worker_class:, client: ::Beez.client) ⇒ Processor
constructor
A new instance of Processor.
- #should_activate_jobs? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(worker_class:, client: ::Beez.client) ⇒ Processor
Returns a new instance of Processor.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/beez/processor.rb', line 5 def initialize(worker_class:, client: ::Beez.client) @client = client @worker_class = worker_class @busy_count = ::Concurrent::AtomicFixnum.new(0) @timer = ::Concurrent::TimerTask.new( run_now: true, execution_interval: worker_poll_interval, timeout_interval: worker_timeout ) { run } end |
Instance Attribute Details
#busy_count ⇒ Object (readonly)
Returns the value of attribute busy_count.
3 4 5 |
# File 'lib/beez/processor.rb', line 3 def busy_count @busy_count end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/beez/processor.rb', line 3 def client @client end |
#timer ⇒ Object (readonly)
Returns the value of attribute timer.
3 4 5 |
# File 'lib/beez/processor.rb', line 3 def timer @timer end |
#worker_class ⇒ Object (readonly)
Returns the value of attribute worker_class.
3 4 5 |
# File 'lib/beez/processor.rb', line 3 def worker_class @worker_class end |
Instance Method Details
#should_activate_jobs? ⇒ Boolean
26 27 28 |
# File 'lib/beez/processor.rb', line 26 def should_activate_jobs? busy_count.value <= worker_max_jobs_to_activate end |
#start ⇒ Object
16 17 18 19 |
# File 'lib/beez/processor.rb', line 16 def start timer.execute self end |
#stop ⇒ Object
21 22 23 24 |
# File 'lib/beez/processor.rb', line 21 def stop timer.shutdown self end |