Class: Cliaws::Sqs
- Inherits:
-
Object
- Object
- Cliaws::Sqs
- Defined in:
- lib/cliaws/sqs.rb
Instance Method Summary collapse
-
#create(qname) ⇒ Object
Creates a queue.
-
#delete(qname, force = false) ⇒ Object
Deletes a queue.
-
#fetch(qname, size) ⇒ Object
Fetches a number of messages.
-
#info(qname) ⇒ Object
Retrieves information about a queue.
-
#initialize(access_key_id, secret_access_key) ⇒ Sqs
constructor
A new instance of Sqs.
-
#list(prefix = nil) ⇒ Object
Lists the created queues.
-
#pop(qname) ⇒ Object
Gets and deletes message.
-
#push(qname, data) ⇒ Object
Adds a message in the queue.
-
#receive(qname) ⇒ Object
Gets a message from the queue, but doesn’t delete it.
-
#size(qname) ⇒ Object
Returns the size of the queue.
Constructor Details
#initialize(access_key_id, secret_access_key) ⇒ Sqs
Returns a new instance of Sqs.
5 6 7 8 9 |
# File 'lib/cliaws/sqs.rb', line 5 def initialize(access_key_id, secret_access_key) logger = Logger.new(STDERR) logger.level = Logger::WARN @sqs = RightAws::SqsGen2.new(access_key_id, secret_access_key, :logger => logger) end |
Instance Method Details
#create(qname) ⇒ Object
Creates a queue
42 43 44 |
# File 'lib/cliaws/sqs.rb', line 42 def create(qname) q(qname, true) end |
#delete(qname, force = false) ⇒ Object
Deletes a queue. force
must be true to delete a queue with pending messages.
47 48 49 |
# File 'lib/cliaws/sqs.rb', line 47 def delete(qname, force=false) q(qname).delete(force) end |
#fetch(qname, size) ⇒ Object
Fetches a number of messages.
27 28 29 |
# File 'lib/cliaws/sqs.rb', line 27 def fetch(qname, size) q(qname).(size) end |
#info(qname) ⇒ Object
Retrieves information about a queue
52 53 54 55 |
# File 'lib/cliaws/sqs.rb', line 52 def info(qname) queue = q(qname) { :visibility_timeout => queue.visibility, :size => queue.size } end |
#list(prefix = nil) ⇒ Object
Lists the created queues.
37 38 39 |
# File 'lib/cliaws/sqs.rb', line 37 def list(prefix=nil) @sqs.queues(prefix) end |
#pop(qname) ⇒ Object
Gets and deletes message.
22 23 24 |
# File 'lib/cliaws/sqs.rb', line 22 def pop(qname) q(qname).pop end |
#push(qname, data) ⇒ Object
Adds a message in the queue.
17 18 19 |
# File 'lib/cliaws/sqs.rb', line 17 def push(qname, data) q(qname).push(data) end |
#receive(qname) ⇒ Object
Gets a message from the queue, but doesn’t delete it.
12 13 14 |
# File 'lib/cliaws/sqs.rb', line 12 def receive(qname) q(qname).receive end |
#size(qname) ⇒ Object
Returns the size of the queue.
32 33 34 |
# File 'lib/cliaws/sqs.rb', line 32 def size(qname) q(qname).size end |