Class: Realm::SNS::Gateway::QueueAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/realm/sns/gateway/queue_adapter.rb

Overview

Provides cleaner SDK over Aws::SQS::Queue

Instance Method Summary collapse

Instance Method Details

#allow_send_messages(source_arn) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/realm/sns/gateway/queue_adapter.rb', line 14

def allow_send_messages(source_arn)
  @queue.set_attributes(attributes: {
                          'Policy' => {
                            'Version' => '2012-10-17',
                            'Statement' => policy_statement(source_arn),
                          }.to_json,
                        })
end

#arnObject



10
11
12
# File 'lib/realm/sns/gateway/queue_adapter.rb', line 10

def arn
  @queue.attributes['QueueArn']
end

#empty?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/realm/sns/gateway/queue_adapter.rb', line 30

def empty?
  attributes.slice(
    'ApproximateNumberOfMessages',
    'ApproximateNumberOfMessagesDelayed',
    'ApproximateNumberOfMessagesNotVisible',
  ).all? { |_, val| val.to_i.zero? }
end

#publish(event_type, message) ⇒ Object



23
24
25
26
27
28
# File 'lib/realm/sns/gateway/queue_adapter.rb', line 23

def publish(event_type, message)
  @queue.send_message(
    message_body: message,
    message_attributes: { 'event_type' => { data_type: 'String', string_value: event_type.to_s } },
  )
end