Class: AwsSqsMoniter::Aws::Builder::SubscriptionBuilder
- Inherits:
-
Object
- Object
- AwsSqsMoniter::Aws::Builder::SubscriptionBuilder
- Defined in:
- lib/aws_sqs_moniter/aws/builder/subscription_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(logger, queue) ⇒ SubscriptionBuilder
constructor
A new instance of SubscriptionBuilder.
Constructor Details
#initialize(logger, queue) ⇒ SubscriptionBuilder
Returns a new instance of SubscriptionBuilder.
5 6 7 8 9 10 11 |
# File 'lib/aws_sqs_moniter/aws/builder/subscription_builder.rb', line 5 def initialize logger, queue @logger = logger @queue = queue @arns = Arns.new @sns = AwsSqsMoniter.sns_client @sqs = AwsSqsMoniter.sqs_client end |
Instance Method Details
#build ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aws_sqs_moniter/aws/builder/subscription_builder.rb', line 13 def build queue_url = @sqs.get_queue_url(queue_name: @queue)[:queue_url] queue_arn = @sqs.get_queue_attributes( queue_url: queue_url, attribute_names: ['QueueArn']).attributes['QueueArn'] topics.each do |topic| topic = EnvironmentalName.new(topic).to_s topic_arn = @arns.sns_topic_arn topic if AwsSqsMoniter.configuration.sns_protocol == 'cqs' @sns. topic_arn: topic_arn, label: "subscribe-#{AwsSqsMoniter.configuration.aws_account_id}-#{Time.now.strftime('%Y%m%d%H%M%S')}", aws_account_id: [AwsSqsMoniter.configuration.aws_account_id], action_name: ['Subscribe'] end @logger.info subscribing_queue: @queue, subscription_topic: topic @sns.subscribe( endpoint: queue_arn, protocol: AwsSqsMoniter.configuration.sns_protocol, topic_arn: topic_arn) end end |