Module: Eventboss::DevelopmentMode
- Extended by:
- Logging
- Defined in:
- lib/eventboss/development_mode.rb
Class Method Summary collapse
Methods included from Logging
Class Method Details
.queue_policy(queue_arn, topic_arn) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/eventboss/development_mode.rb', line 32 def queue_policy(queue_arn, topic_arn) { "Version": "2012-10-17", "Statement": [{ "Sid": "queue-policy-#{queue_arn}-#{topic_arn}", "Effect": "Allow", "Principal": "*", "Action": ["SQS:SendMessage"], "Resource": "#{queue_arn}", "Condition": { "ArnEquals": { "aws:SourceArn": "#{topic_arn}" } } }] } end |
.setup_infrastructure(queues) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eventboss/development_mode.rb', line 8 def setup_infrastructure(queues) sns_client = Eventboss.configuration.sns_client sqs_client = Eventboss.configuration.sqs_client queues.each do |queue, listener| topic_name = Eventboss::Topic.build_name(**listener.) logger.info('development-mode') { "Creating topic #{topic_name}..." } topic = sns_client.create_topic(name: topic_name) logger.info('development-mode') { "Creating queue #{queue.name}..." } sqs_client.create_queue(queue_name: queue.name) logger.info('development-mode') { "Creating deadletter queue #{queue.name}-deadletter..." } sqs_client.create_queue(queue_name: "#{queue.name}-deadletter") logger.info('development-mode') { "Setting up queue #{queue.name} policy..." } policy = queue_policy(queue.arn, topic.topic_arn) sqs_client.set_queue_attributes(queue_url: queue.url, attributes: { Policy: policy.to_json }) logger.info('development-mode') { "Creating subscription for topic #{topic.topic_arn} and #{queue.arn}..." } sns_client.create_subscription(topic_arn: topic.topic_arn, queue_arn: queue.arn) end end |