Sha256: 2e0381079a49701eca2a8b402f581f598d9e6d26edb6fc5c5227dfacda43a479

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'rufus-scheduler'
require 'redis'
require 'connection_pool'

module Dashing
  class Configuration

    attr_reader   :redis
    attr_accessor :scheduler, :view_path, :jobs_path, :redis_namespace,
                  :engine_path, :dashboards_path, :dashboard_layout,
                  :widgets_path, :default_dashboard, :auth_token, :devise_allowed_models,
                  :redis_host, :redis_port, :redis_password

    def initialize
      @scheduler              = ::Rufus::Scheduler.new
      @redis_host             = '127.0.0.1'
      @redis_port             = '6379'
      @redis_password         = nil
      @redis_namespace        = 'dashing_events'
      @view_path              = 'app/views/dashing/'
      @jobs_path              = 'app/jobs/'
      @engine_path            = '/dashing'
      @dashboards_path        = 'app/views/dashing/dashboards/'
      @dashboard_layout       = 'dashing/dashboard'
      @widgets_path           = 'app/views/dashing/widgets/'
      @default_dashboard      = nil
      @auth_token             = nil
      @devise_allowed_models  = []
    end

    def redis
      @redis ||= ::ConnectionPool::Wrapper.new(size: request_thread_count, timeout: 3) { ::Redis.new(host: redis_host, port: redis_port, password: redis_password) }
    end

    private

    def request_thread_count
      if defined?(::Puma) && ::Puma.respond_to?(:cli_config)
        ::Puma.cli_config.options.fetch(:max_threads, 5).to_i
      else
        5
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dashing-rails-1.0.3 lib/dashing/configuration.rb
dashing-rails-1.0.2 lib/dashing/configuration.rb