Sha256: 51d81954489b792bcf525741155526e75b14ba70314c4c3e585ab22d81fb7564

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

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    => 900,
      :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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oas-log-collector-0.1.6 lib/oas/log_collector.rb
oas-log-collector-0.1.5 lib/oas/log_collector.rb