require 'oas/log_collector/version' require 'connection_pool' require 'redis' module OAS module LogCollector DEFAULTS = { :sources => [], :source_logs_path => "/tmp", :logs_path => "~/oas-log-collector", :days_to_search => 10, :files_to_copy => 90, :sleep_seconds => 56400, :redis_url => 'redis://localhost:6379/0' } extend self def options @options ||= DEFAULTS.dup end def redis(&block) @redis ||= ConnectionPool.new(:timeout => 1, :size => options[:sources].size) { Redis.connect(:url => options[:redis_url]) } raise ArgumentError, "requires a block" if !block @redis.with(&block) end def redis=(conn) if conn.is_a?(ConnectionPool) @redis = conn else raise ArgumentError, "redis= requires a ConnectionPool" end end end end