Sha256: 27f527eb286e92293ba90cedc8f22f2ff200a40c570c672f5678475bbd856d19

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

module Propono
  class QueueSubscription

    include Sns
    include Sqs

    attr_reader :topic_arn, :queue

    def self.create(topic_id)
      new(topic_id).tap do |subscription|
        subscription.create
      end
    end

    def initialize(topic_id)
      @topic_id = topic_id
    end

    def create
      @topic = TopicCreator.find_or_create(@topic_id)
      @queue = QueueCreator.find_or_create(queue_name)
      sns.subscribe(@topic.arn, @queue.arn, 'sqs')
    end

    def queue_name
      @queue_name ||= "#{config.application_name.gsub(" ", "_")}::#{@topic_id}"
    end

    private

    def config
      Configuration.instance
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propono-0.4.0 lib/propono/components/queue_subscription.rb