Class: Propono::QueueSubscription
- Inherits:
-
Object
- Object
- Propono::QueueSubscription
- Defined in:
- lib/propono/components/queue_subscription.rb
Instance Attribute Summary collapse
-
#aws_client ⇒ Object
readonly
Returns the value of attribute aws_client.
-
#corrupt_queue ⇒ Object
readonly
Returns the value of attribute corrupt_queue.
-
#failed_queue ⇒ Object
readonly
Returns the value of attribute failed_queue.
-
#propono_config ⇒ Object
readonly
Returns the value of attribute propono_config.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
-
#slow_queue ⇒ Object
readonly
Returns the value of attribute slow_queue.
-
#topic_arn ⇒ Object
readonly
Returns the value of attribute topic_arn.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #create_and_subscribe_main_queue ⇒ Object
- #create_and_subscribe_slow_queue ⇒ Object
- #create_misc_queues ⇒ Object
-
#initialize(aws_client, propono_config, topic_name) ⇒ QueueSubscription
constructor
A new instance of QueueSubscription.
Constructor Details
#initialize(aws_client, propono_config, topic_name) ⇒ QueueSubscription
Returns a new instance of QueueSubscription.
12 13 14 15 16 17 18 19 |
# File 'lib/propono/components/queue_subscription.rb', line 12 def initialize(aws_client, propono_config, topic_name) @aws_client = aws_client @propono_config = propono_config @topic_name = topic_name @suffixed_topic_name = "#{topic_name}#{propono_config.queue_suffix}" @suffixed_slow_topic_name = "#{topic_name}#{propono_config.queue_suffix}-slow" @queue_name = "#{propono_config.application_name.tr(" ", "_")}-#{@suffixed_topic_name}" end |
Instance Attribute Details
#aws_client ⇒ Object (readonly)
Returns the value of attribute aws_client.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def aws_client @aws_client end |
#corrupt_queue ⇒ Object (readonly)
Returns the value of attribute corrupt_queue.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def corrupt_queue @corrupt_queue end |
#failed_queue ⇒ Object (readonly)
Returns the value of attribute failed_queue.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def failed_queue @failed_queue end |
#propono_config ⇒ Object (readonly)
Returns the value of attribute propono_config.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def propono_config @propono_config end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def queue @queue end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def queue_name @queue_name end |
#slow_queue ⇒ Object (readonly)
Returns the value of attribute slow_queue.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def slow_queue @slow_queue end |
#topic_arn ⇒ Object (readonly)
Returns the value of attribute topic_arn.
4 5 6 |
# File 'lib/propono/components/queue_subscription.rb', line 4 def topic_arn @topic_arn end |
Class Method Details
.create(*args) ⇒ Object
6 7 8 9 10 |
# File 'lib/propono/components/queue_subscription.rb', line 6 def self.create(*args) new(*args).tap do |subscription| subscription.create end end |
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 |
# File 'lib/propono/components/queue_subscription.rb', line 21 def create raise ProponoError.new("topic_name is nil") unless @topic_name create_and_subscribe_main_queue create_and_subscribe_slow_queue create_misc_queues end |
#create_and_subscribe_main_queue ⇒ Object
28 29 30 31 32 33 |
# File 'lib/propono/components/queue_subscription.rb', line 28 def create_and_subscribe_main_queue @queue = aws_client.create_queue(queue_name) topic = aws_client.create_topic(@suffixed_topic_name) aws_client.subscribe_sqs_to_sns(@queue, topic) aws_client.set_sqs_policy(@queue, generate_policy(@queue, topic)) end |
#create_and_subscribe_slow_queue ⇒ Object
40 41 42 43 44 45 |
# File 'lib/propono/components/queue_subscription.rb', line 40 def create_and_subscribe_slow_queue @slow_queue = aws_client.create_queue("#{queue_name}-slow") slow_topic = aws_client.create_topic(@suffixed_slow_topic_name) aws_client.subscribe_sqs_to_sns(@slow_queue, slow_topic) aws_client.set_sqs_policy(@slow_queue, generate_policy(@slow_queue, slow_topic)) end |
#create_misc_queues ⇒ Object
35 36 37 38 |
# File 'lib/propono/components/queue_subscription.rb', line 35 def create_misc_queues @failed_queue = aws_client.create_queue("#{queue_name}-failed") @corrupt_queue = aws_client.create_queue("#{queue_name}-corrupt") end |