Sha256: a62294650efc4ed7a6ba525b62159f0df29a110f28103f279e39792cc12391bb
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# Simple library to aid in tracking statistics regarding Kthxbye and its workers. # Submits jobs processed stats, total failures, total uptime, etc. # Puts all stats in stats:x vars in Redis. Super flexible, made to allow tracking # of any kind of count internally # # Built in stats (tracked by Kthxbye internals) include the following # # processed - the count of processed jobs # <worker>:processed - the count a given worker has processed # failures - the count of failed jobs module Kthxbye module Stats extend self extend Helper # get count for a given stat (can also use [] method) def get( stat ) redis.get( "stat:#{stat}" ).to_i end alias_method :[], :get # increment a count by a given value (defaults to 1) def incr( stat, by=1 ) redis.incrby("stat:#{stat}", by) end # decrement a count by a given value (defaults to 1) def decr( stat, by=1 ) redis.decrby("stat:#{stat}", by) end # reset this stat to 0 def reset( stat ) redis.del( "stat:#{stat}" ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kthxbye-1.3.2 | lib/kthxbye/stats.rb |
kthxbye-1.3.0 | lib/kthxbye/stats.rb |