Sha256: 80f736d2a724b1d9587083479becb2105554fc7e2e6a55cdde62f12b68843625

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

module Propono
  class QueueSubscriber

    include Sns
    include Sqs

    attr_reader :topic_arn, :queue

    def self.subscribe(topic_id)
      new(topic_id).subscribe
    end

    def initialize(topic_id)
      @topic_id = topic_id
    end

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

    private

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

    def config
      Configuration.instance
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
propono-0.3.0 lib/propono/services/queue_subscriber.rb
propono-0.2.0 lib/propono/services/queue_subscriber.rb