Sha256: 61c63043c02569c646ab4c40cc212b3dde28784cb60399563b2e5066d1ebbf03

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

# coding: utf-8
Dir[File.dirname(__FILE__) + '/backends/*.rb'].each {|file| require file  }

# base Splash Module
module Splash

  # generic backends module
  module Backends
    include Splash::Config
    include Splash::Constants

    # factory for backend
    # @param [Symbol] store the name of the store actually in [:execution_trace]
    # @return [Splash::Backends::<Type>|Hash] with type in [:redis,:file] or Exiter case :configuration_error
    def get_backend(store)
      splash_exit case: :configuration_error, more: "backend definition failure" if get_config[:backends][:stores][store].nil?
      backend = get_config[:backends][:stores][store][:type].to_s
      aclass = "Splash::Backends::#{backend.capitalize}"
      begin
        return Kernel.const_get(aclass)::new(store)
      rescue
        splash_exit case: :configuration_error, more: "Backend specified for store #{store} inexistant : #{backend}"
      end
    end

    # return list of configured backand
    # @return [Hash] the backends hash list/structure
    def list_backends
      return get_config[:backends][:stores]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prometheus-splash-0.9.1 lib/splash/backends.rb
prometheus-splash-0.9.0 lib/splash/backends.rb
prometheus-splash-0.8.6 lib/splash/backends.rb
prometheus-splash-0.8.5 lib/splash/backends.rb
prometheus-splash-0.8.4 lib/splash/backends.rb