Class: CI::Queue::Redis::GrindRecord
- Inherits:
-
Object
- Object
- CI::Queue::Redis::GrindRecord
- Defined in:
- lib/ci/queue/redis/grind_record.rb
Instance Method Summary collapse
- #error_reports ⇒ Object (also: #failed_tests)
- #fetch_stats(stat_names) ⇒ Object
-
#initialize(queue, redis, config) ⇒ GrindRecord
constructor
A new instance of GrindRecord.
- #pop_warnings ⇒ Object
- #record_error(payload, stats: nil) ⇒ Object
- #record_success(stats: nil) ⇒ Object
- #record_warning(_, _) ⇒ Object
Constructor Details
#initialize(queue, redis, config) ⇒ GrindRecord
Returns a new instance of GrindRecord.
7 8 9 10 11 |
# File 'lib/ci/queue/redis/grind_record.rb', line 7 def initialize(queue, redis, config) @queue = queue @redis = redis @config = config end |
Instance Method Details
#error_reports ⇒ Object Also known as: failed_tests
33 34 35 |
# File 'lib/ci/queue/redis/grind_record.rb', line 33 def error_reports redis.lrange(key('error-reports'), 0, -1) end |
#fetch_stats(stat_names) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/ci/queue/redis/grind_record.rb', line 37 def fetch_stats(stat_names) counts = redis.pipelined do |pipeline| stat_names.each { |c| pipeline.hvals(key(c)) } end stat_names.zip(counts.map { |values| values.map(&:to_f).inject(:+).to_f }).to_h end |
#pop_warnings ⇒ Object
44 45 46 |
# File 'lib/ci/queue/redis/grind_record.rb', line 44 def pop_warnings [] end |
#record_error(payload, stats: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ci/queue/redis/grind_record.rb', line 13 def record_error(payload, stats: nil) redis.pipelined do |pipeline| pipeline.lpush( key('error-reports'), payload.force_encoding(Encoding::BINARY), ) pipeline.expire(key('error-reports'), config.redis_ttl) record_stats(stats, pipeline: pipeline) end nil end |
#record_success(stats: nil) ⇒ Object
25 26 27 |
# File 'lib/ci/queue/redis/grind_record.rb', line 25 def record_success(stats: nil) record_stats(stats) end |
#record_warning(_, _) ⇒ Object
29 30 31 |
# File 'lib/ci/queue/redis/grind_record.rb', line 29 def record_warning(_,_) #do nothing end |