Class: Shoryuken::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name) ⇒ Queue

Returns a new instance of Queue


5
6
7
8
9
# File 'lib/shoryuken/queue.rb', line 5

def initialize(client, name)
  self.name   = name
  self.client = client
  self.url    = client.get_queue_url(queue_name: name).queue_url
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


3
4
5
# File 'lib/shoryuken/queue.rb', line 3

def client
  @client
end

#nameObject

Returns the value of attribute name


3
4
5
# File 'lib/shoryuken/queue.rb', line 3

def name
  @name
end

#urlObject

Returns the value of attribute url


3
4
5
# File 'lib/shoryuken/queue.rb', line 3

def url
  @url
end

Instance Method Details

#delete_messages(options) ⇒ Object


18
19
20
# File 'lib/shoryuken/queue.rb', line 18

def delete_messages(options)
  client.delete_message_batch(options.merge(queue_url: url))
end

#receive_messages(options) ⇒ Object


34
35
36
37
38
# File 'lib/shoryuken/queue.rb', line 34

def receive_messages(options)
  client.receive_message(options.merge(queue_url: url)).
    messages.
    map { |m| Message.new(client, self, m) }
end

#send_message(options) ⇒ Object


22
23
24
25
26
27
28
# File 'lib/shoryuken/queue.rb', line 22

def send_message(options)
  options = sanitize_message!(options).merge(queue_url: url)

  Shoryuken.client_middleware.invoke(options) do
    client.send_message(options)
  end
end

#send_messages(options) ⇒ Object


30
31
32
# File 'lib/shoryuken/queue.rb', line 30

def send_messages(options)
  client.send_message_batch(sanitize_messages!(options).merge(queue_url: url))
end

#visibility_timeoutObject


11
12
13
14
15
16
# File 'lib/shoryuken/queue.rb', line 11

def visibility_timeout
  client.get_queue_attributes(
    queue_url: url,
    attribute_names: ['VisibilityTimeout']
  ).attributes['VisibilityTimeout'].to_i
end