Class: Realm::SNS::Gateway::QueueAdapter
- Inherits:
-
Object
- Object
- Realm::SNS::Gateway::QueueAdapter
- Defined in:
- lib/realm/sns/gateway/queue_adapter.rb
Overview
Provides cleaner SDK over Aws::SQS::Queue
Instance Method Summary collapse
- #allow_send_messages(source_arn) ⇒ Object
- #arn ⇒ Object
- #empty? ⇒ Boolean
- #publish(event_type, message) ⇒ Object
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 (source_arn) @queue.set_attributes(attributes: { 'Policy' => { 'Version' => '2012-10-17', 'Statement' => policy_statement(source_arn), }.to_json, }) end |
#arn ⇒ Object
10 11 12 |
# File 'lib/realm/sns/gateway/queue_adapter.rb', line 10 def arn @queue.attributes['QueueArn'] end |
#empty? ⇒ 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, ) @queue.( message_body: , message_attributes: { 'event_type' => { data_type: 'String', string_value: event_type.to_s } }, ) end |