Class: TxghQueue::Backends::Sqs::Queue
- Inherits:
-
Object
- Object
- TxghQueue::Backends::Sqs::Queue
- Defined in:
- lib/txgh-queue/backends/sqs/queue.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #client ⇒ Object
- #delete_message(receipt_handle) ⇒ Object
-
#initialize(options = {}) ⇒ Queue
constructor
A new instance of Queue.
- #receive_message(options = {}) ⇒ Object
- #send_message(body, options = {}) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Queue
Returns a new instance of Queue.
9 10 11 12 13 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 9 def initialize( = {}) @name = .fetch(:name) @region = .fetch(:region) @events = .fetch(:events, []) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
7 8 9 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 7 def events @events end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 7 def name @name end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
7 8 9 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 7 def region @region end |
Instance Method Details
#client ⇒ Object
15 16 17 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 15 def client @client ||= Aws::SQS::Client.new(region: region) end |
#delete_message(receipt_handle) ⇒ Object
32 33 34 35 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 32 def (receipt_handle) params = { queue_url: url, receipt_handle: receipt_handle } client.(params) end |
#receive_message(options = {}) ⇒ Object
23 24 25 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 23 def ( = {}) client.(.merge(queue_url: url)) end |
#send_message(body, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 27 def (body, = {}) params = .merge(message_body: body, queue_url: url) client.(params) end |
#url ⇒ Object
19 20 21 |
# File 'lib/txgh-queue/backends/sqs/queue.rb', line 19 def url @url ||= client.get_queue_url(queue_name: name).queue_url end |