class Ravanello::Analyze
Redis
analyze command
Attributes
options[R]
Public Class Methods
new(options)
click to toggle source
# File lib/ravanello/analyze.rb, line 11 def initialize(options) @options = options end
Public Instance Methods
call()
click to toggle source
# File lib/ravanello/analyze.rb, line 15 def call router = Yaml.new(File.read(options.fetch('rules'))).call cursor = Redis::Cursor.new(redis, limit: redis_fetch_limit) statistics = Analyzer.new(router, cursor).call print(statistics) print_samples(statistics) end
Private Instance Methods
print(statistics)
click to toggle source
# File lib/ravanello/analyze.rb, line 25 def print(statistics) Ravanello::Formatter.new(statistics).call.each { |line| puts line } end
print_samples(statistics)
click to toggle source
# File lib/ravanello/analyze.rb, line 29 def print_samples(statistics) return if statistics.data['*'].nil? puts 'Discard sample keys:' samples = (1..10).map { statistics.data['*'].samples.sample.name }.uniq samples.each { |sample| puts "\t#{sample}" } end
redis()
click to toggle source
# File lib/ravanello/analyze.rb, line 36 def redis @redis ||= ::Redis.new(url: ENV['REDIS']) end
redis_fetch_limit()
click to toggle source
# File lib/ravanello/analyze.rb, line 40 def redis_fetch_limit fetch_limit = ENV['FETCH_LIMIT'] fetch_limit.nil? || fetch_limit == '' ? nil : fetch_limit.to_i end