Class: Flatware::Worker
- Inherits:
-
Object
- Object
- Flatware::Worker
- Defined in:
- lib/flatware/worker.rb
Overview
executes tests and sends results to the sink
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
-
#sink ⇒ Object
readonly
Returns the value of attribute sink.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, runner, sink_endpoint) ⇒ Worker
constructor
A new instance of Worker.
- #listen ⇒ Object
Constructor Details
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/flatware/worker.rb', line 9 def id @id end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
9 10 11 |
# File 'lib/flatware/worker.rb', line 9 def runner @runner end |
#sink ⇒ Object (readonly)
Returns the value of attribute sink.
9 10 11 |
# File 'lib/flatware/worker.rb', line 9 def sink @sink end |
Class Method Details
.spawn(count:, runner:, sink:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flatware/worker.rb', line 18 def self.spawn(count:, runner:, sink:, **) Flatware.configuration.before_fork.call count.times do |i| fork do $0 = "flatware worker #{i}" ENV['TEST_ENV_NUMBER'] = i.to_s Flatware.configuration.after_fork.call(i) new(i, runner, sink).listen end end end |
Instance Method Details
#listen ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/flatware/worker.rb', line 30 def listen (times: 10, wait: 0.1) do job = sink.ready id until want_to_quit? || job.sentinel? job.worker = id sink.started job run job job = sink.ready id end end end |