class Announce::Adapters::ShoryukenAdapter::Queue
Public Instance Methods
arn()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 127 def arn account_id = Shoryuken::Client.account_id region = sqs.config[:region] "arn:aws:sqs:#{region}:#{account_id}:#{name}" end
create()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 118 def create create_attributes = default_options.merge((options[:queues] || {}).stringify_keys) dlq_arn = create_dlq create_attributes['RedrivePolicy'] = %Q{{"maxReceiveCount":"10", "deadLetterTargetArn":"#{dlq_arn}"}"} sqs.create_queue(queue_name: name, attributes: create_attributes)[:queue_url] end
create_dlq()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 133 def create_dlq dlq_name = "#{name}_failures" dlq_options = { 'MaximumMessageSize' => "#{(256 * 1024)}", 'MessageRetentionPeriod' => "#{2 * 7 * 24 * 60 * 60}" # 2 weeks in seconds } dlq = sqs.create_queue( queue_name: dlq_name, attributes: dlq_options ) attrs = sqs.get_queue_attributes( queue_url: dlq[:queue_url], attribute_names: ['QueueArn'] ) attrs.attributes['QueueArn'] end
default_options()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 154 def default_options { 'DelaySeconds' => '0', 'MaximumMessageSize' => "#{256 * 1024}", 'VisibilityTimeout' => "#{60 * 60}", # 1 hour in seconds 'ReceiveMessageWaitTimeSeconds' => '0', 'MessageRetentionPeriod' => "#{7 * 24 * 60 * 60}", # 1 week in seconds 'Policy' => policy } end
policy()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 165 def policy account_id = Shoryuken::Client.account_id region = sqs.config[:region] { "Version" => "2012-10-17", "Id" => "AnnounceSNStoSQS", "Statement" => [ { "Sid" => "1", "Effect" => "Allow", "Principal" => { "AWS" => "*" }, "Action" => "sqs:*", "Resource" => arn, "Condition" => { "ArnLike" => { "aws:SourceArn" => "arn:aws:sns:#{region}:#{account_id}:*" } } } ] }.to_json end
sqs()
click to toggle source
# File lib/announce/adapters/shoryuken_adapter.rb, line 190 def sqs Shoryuken::Client.sqs end