Sha256: 37610dba422a3cab79ffb37d2e02bc827bf3bffb4a2520bd5fb4340141405ccb

Contents?: true

Size: 1003 Bytes

Versions: 6

Compression:

Stored size: 1003 Bytes

Contents

module Shoryuken
  class Client
    @@queues = {}
    @@topics = {}

    class << self
      def queues(name)
        @@queues[name.to_s] ||= Shoryuken::Queue.new(sqs, name)
      end

      def sns
        @sns ||= Aws::SNS::Client.new(aws_client_options(:sns_endpoint))
      end

      def sns_arn
        @sns_arn ||= SnsArn
      end

      def sqs
        @sqs ||= Aws::SQS::Client.new(aws_client_options(:sqs_endpoint))
      end

      def topics(name)
        @@topics[name.to_s] ||= Topic.new(name, sns)
      end

      attr_accessor :account_id
      attr_writer :sns, :sqs, :sqs_resource, :sns_arn

      private

      def aws_client_options(service_endpoint_key)
        environment_endpoint = ENV["AWS_#{service_endpoint_key.to_s.upcase}"]
        explicit_endpoint = Shoryuken.options[:aws][service_endpoint_key] || environment_endpoint
        options = {}
        options[:endpoint] = explicit_endpoint unless explicit_endpoint.to_s.empty?
        options
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shoryuken-2.0.11 lib/shoryuken/client.rb
shoryuken-2.0.4 lib/shoryuken/client.rb
shoryuken-2.0.3 lib/shoryuken/client.rb
shoryuken-2.0.2 lib/shoryuken/client.rb
shoryuken-2.0.1 lib/shoryuken/client.rb
shoryuken-2.0.0 lib/shoryuken/client.rb