Class: Mutant::Parallel::Connection::Reader Private
- Inherits:
-
Object
- Object
- Mutant::Parallel::Connection::Reader
- Defined in:
- lib/mutant/parallel/connection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #log ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #error ⇒ Object private
-
#initialize ⇒ Reader
constructor
private
A new instance of Reader.
-
#read_till_final ⇒ Object
private
rubocop:disable Metrics/MethodLength.
- #result ⇒ Object private
Constructor Details
#initialize ⇒ Reader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Reader.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mutant/parallel/connection.rb', line 32 def initialize(*) super @buffer = +'' @log = +'' # Array of size max 1 as surrogate for # terrible default nil ivars. @errors = [] @lengths = [] @results = [] end |
Instance Attribute Details
#log ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/mutant/parallel/connection.rb', line 22 def log @log end |
Class Method Details
.read_response(job:, **attributes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mutant/parallel/connection.rb', line 45 def self.read_response(job:, **attributes) reader = new(**attributes).read_till_final Response.new( error: reader.error, job:, log: reader.log, result: reader.result ) end |
Instance Method Details
#error ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/mutant/parallel/connection.rb', line 24 def error Util.max_one(@errors) end |
#read_till_final ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/MethodLength
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mutant/parallel/connection.rb', line 57 def read_till_final readers = [response_reader, log_reader] until !@results.empty? || error status = deadline.status break timeout unless status.ok? reads, _others = io.select(readers, nil, nil, status.time_left) break timeout unless reads reads.each do |ready| if ready.equal?(response_reader) advance_result else advance_log end end end self end |
#result ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/mutant/parallel/connection.rb', line 28 def result Util.max_one(@results) end |