Class: CI::Queue::BuildRecord
- Inherits:
-
Object
- Object
- CI::Queue::BuildRecord
- Defined in:
- lib/ci/queue/build_record.rb
Instance Attribute Summary collapse
-
#error_reports ⇒ Object
readonly
Returns the value of attribute error_reports.
Instance Method Summary collapse
- #fetch_stats(stat_names) ⇒ Object
-
#initialize(queue) ⇒ BuildRecord
constructor
A new instance of BuildRecord.
- #progress ⇒ Object
- #queue_exhausted? ⇒ Boolean
- #record_error(id, payload, stat_delta: nil) ⇒ Object
- #record_requeue(id) ⇒ Object
- #record_stats(builds_stats) ⇒ Object
- #record_stats_delta(delta, pipeline: nil) ⇒ Object
- #record_success(id, skip_flaky_record: false, acknowledge: true) ⇒ Object
- #report_worker_error(_) ⇒ Object
- #reset_stats(stat_names) ⇒ Object
- #reset_worker_error ⇒ Object
- #worker_errors ⇒ Object
Constructor Details
#initialize(queue) ⇒ BuildRecord
Returns a new instance of BuildRecord.
7 8 9 10 11 |
# File 'lib/ci/queue/build_record.rb', line 7 def initialize(queue) @queue = queue @error_reports = {} @stats = {} end |
Instance Attribute Details
#error_reports ⇒ Object (readonly)
Returns the value of attribute error_reports.
5 6 7 |
# File 'lib/ci/queue/build_record.rb', line 5 def error_reports @error_reports end |
Instance Method Details
#fetch_stats(stat_names) ⇒ Object
48 49 50 |
# File 'lib/ci/queue/build_record.rb', line 48 def fetch_stats(stat_names) stat_names.zip(stats.values_at(*stat_names).map(&:to_f)).to_h end |
#progress ⇒ Object
13 14 15 |
# File 'lib/ci/queue/build_record.rb', line 13 def progress @queue.progress end |
#queue_exhausted? ⇒ Boolean
17 18 19 |
# File 'lib/ci/queue/build_record.rb', line 17 def queue_exhausted? @queue.exhausted? end |
#record_error(id, payload, stat_delta: nil) ⇒ Object
21 22 23 24 |
# File 'lib/ci/queue/build_record.rb', line 21 def record_error(id, payload, stat_delta: nil) error_reports[id] = payload true end |
#record_requeue(id) ⇒ Object
31 32 33 |
# File 'lib/ci/queue/build_record.rb', line 31 def record_requeue(id) true end |
#record_stats(builds_stats) ⇒ Object
35 36 37 38 |
# File 'lib/ci/queue/build_record.rb', line 35 def record_stats(builds_stats) return unless builds_stats stats.merge!(builds_stats) end |
#record_stats_delta(delta, pipeline: nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/ci/queue/build_record.rb', line 40 def record_stats_delta(delta, pipeline: nil) return if delta.nil? || delta.empty? delta.each do |stat_name, value| next unless value.is_a?(Numeric) || value.to_s.match?(/\A-?\d+\.?\d*\z/) stats[stat_name] = (stats[stat_name] || 0).to_f + value.to_f end end |
#record_success(id, skip_flaky_record: false, acknowledge: true) ⇒ Object
26 27 28 29 |
# File 'lib/ci/queue/build_record.rb', line 26 def record_success(id, skip_flaky_record: false, acknowledge: true) error_reports.delete(id) true end |
#report_worker_error(_) ⇒ Object
56 |
# File 'lib/ci/queue/build_record.rb', line 56 def report_worker_error(_); end |
#reset_stats(stat_names) ⇒ Object
52 53 54 |
# File 'lib/ci/queue/build_record.rb', line 52 def reset_stats(stat_names) stat_names.each { |s| stats.delete(s) } end |
#reset_worker_error ⇒ Object
58 |
# File 'lib/ci/queue/build_record.rb', line 58 def reset_worker_error; end |
#worker_errors ⇒ Object
60 61 62 |
# File 'lib/ci/queue/build_record.rb', line 60 def worker_errors {} end |