Sha256: 81256e6b1acd1d84520ccbeb842af6124a2cfe3d17a5283bbdef0bf622126c03

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'fog'

require_relative 'fogable'


module Ryespy
  module Listener
    class RaxCF < Base
      
      include Listener::Fogable
      
      REDIS_KEY_PREFIX  = 'rax_cf'.freeze
      SIDEKIQ_JOB_CLASS = 'RyespyRaxCFJob'.freeze
      
      def initialize(opts = {})
        @config = {
          :auth_url  => Fog::Rackspace.const_get(
            "#{opts[:endpoint].upcase}_AUTH_ENDPOINT"
          ),
          :region    => opts[:region].downcase.to_sym,
          :username  => opts[:username],
          :api_key   => opts[:api_key],
          :directory => opts[:container],
        }
        
        super(opts)
      end
      
      private
      
      def connect_service
        @fog_storage = Fog::Storage.new({
          :provider           => 'Rackspace',
          :rackspace_auth_url => @config[:auth_url],
          :rackspace_region   => @config[:region],
          :rackspace_username => @config[:username],
          :rackspace_api_key  => @config[:api_key],
        })
      end
      
      def redis_key
        # CF container (directory) is unique across an account (region?).
        [
          REDIS_KEY_PREFIX,
          @config[:username],
          @config[:directory],
          @config[:region],
        ].join(':')
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ryespy-1.0.0 lib/ryespy/listener/rax_cf.rb