Sha256: 60dabd4068a8dfc922931bf0dbf668163618816058cdac24882657178fe24f0c

Contents?: true

Size: 1.82 KB

Versions: 12

Compression:

Stored size: 1.82 KB

Contents

# coding: utf-8

# base Splash module
module Splash

  # Splash Transports namespace
  module Transports
    include Splash::Config


    # factory for Splash::Transports::Rabbitmq::Subscriber
    # @param [Hash] options
    # @return [Splash::Transports::Rabbitmq::Subscriber|Hash] Subscriber or Exiter case :configuration_error
    def get_default_subscriber(options)
      config = get_config.transports
      transport = config[:active]
      host = config[transport][:host]
      port = config[transport][:port]
      unless verify_service host: host, port: port then
        return  { :case => :service_dependence_missing, :more => "RabbitMQ Transport not available." }
       end
      aclass = "Splash::Transports::#{transport.capitalize}::Subscriber"
      begin
        return Kernel.const_get(aclass)::new(options)
      rescue
        return { :case => :configuration_error, :more => "Transport specified for queue #{options[:queue]} configuration error : #{transport}"}
      end
    end

    # factory for Splash::Transports::Rabbitmq::Client
    # @return [Splash::Transports::Rabbitmq::Client|Hash] Client or Exiter case :configuration_error
    def get_default_client
      config = get_config.transports
      transport = config[:active]
      host = config[transport][:host]
      port = config[transport][:port]
      unless verify_service host: host, port: port then
        return  { :case => :service_dependence_missing, :more => "RabbitMQ Transport not available." }
       end
      aclass = "Splash::Transports::#{transport.to_s.capitalize}::Client"
      begin
        return Kernel.const_get(aclass)::new
      rescue
        return { :case => :configuration_error, :more => "Transport configuration error : #{transport}"}
      end
    end

  end
end

Dir[File.dirname(__FILE__) + '/transports/*.rb'].each {|file| require file  }

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
prometheus-splash-0.9.1 lib/splash/transports.rb
prometheus-splash-0.9.0 lib/splash/transports.rb
prometheus-splash-0.8.6 lib/splash/transports.rb
prometheus-splash-0.8.5 lib/splash/transports.rb
prometheus-splash-0.8.4 lib/splash/transports.rb
prometheus-splash-0.8.3 lib/splash/transports.rb
prometheus-splash-0.8.2 lib/splash/transports.rb
prometheus-splash-0.8.1 lib/splash/transports.rb
prometheus-splash-0.8.0 lib/splash/transports.rb
prometheus-splash-0.7.0 lib/splash/transports.rb
prometheus-splash-0.6.1 lib/splash/transports.rb
prometheus-splash-0.6.0 lib/splash/transports.rb