Class: SimpleSqs::Queue
- Inherits:
-
Object
- Object
- SimpleSqs::Queue
- Defined in:
- lib/simple_sqs/queue.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #approximate_number_of_messages ⇒ Object
-
#initialize(queue_url:) ⇒ Queue
constructor
A new instance of Queue.
- #send_message(event_name:, arguments: []) ⇒ Object
Constructor Details
#initialize(queue_url:) ⇒ Queue
Returns a new instance of Queue.
4 5 6 7 8 9 10 11 |
# File 'lib/simple_sqs/queue.rb', line 4 def initialize queue_url: @queue_url = queue_url @client = Aws::SQS::Client.new( access_key_id: ENV.fetch('SIMPLE_SQS_PUBLIC_KEY'), secret_access_key: ENV.fetch('SIMPLE_SQS_SECRET_KEY'), region: ENV.fetch('SIMPLE_SQS_REGION') ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
2 3 4 |
# File 'lib/simple_sqs/queue.rb', line 2 def client @client end |
Instance Method Details
#approximate_number_of_messages ⇒ Object
27 28 29 |
# File 'lib/simple_sqs/queue.rb', line 27 def get_attribute('ApproximateNumberOfMessages') end |
#send_message(event_name:, arguments: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/simple_sqs/queue.rb', line 13 def event_name:, arguments: [] body = {'Events' => [ {'EventType' => event_name, 'EventTimestamp' => Time.now.to_s, 'Arguments' => arguments } ]} resp = client.( queue_url: @queue_url, message_body: body.to_json, ) end |