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) ⇒ Object
- #record_stats(stats, pipeline: nil) ⇒ Object
- #record_success ⇒ 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
45 46 47 |
# File 'lib/ci/queue/redis/grind_record.rb', line 45 def error_reports redis.lrange(key('error-reports'), 0, -1) end |
#fetch_stats(stat_names) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ci/queue/redis/grind_record.rb', line 49 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
56 57 58 |
# File 'lib/ci/queue/redis/grind_record.rb', line 56 def pop_warnings [] end |
#record_error(payload) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ci/queue/redis/grind_record.rb', line 13 def record_error(payload) redis.pipelined do |pipeline| pipeline.lpush( key('error-reports'), payload, ) pipeline.expire(key('error-reports'), config.redis_ttl) end nil end |
#record_stats(stats, pipeline: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ci/queue/redis/grind_record.rb', line 27 def record_stats(stats, pipeline: nil) return unless stats if pipeline stats.each do |stat_name, stat_value| pipeline.hset(key(stat_name), config.worker_id, stat_value) pipeline.expire(key(stat_name), config.redis_ttl) end else redis.pipelined do |p| record_stats(stats, pipeline: p) end end end |
#record_success ⇒ Object
24 25 |
# File 'lib/ci/queue/redis/grind_record.rb', line 24 def record_success end |
#record_warning(_, _) ⇒ Object
41 42 43 |
# File 'lib/ci/queue/redis/grind_record.rb', line 41 def record_warning(_,_) #do nothing end |