Class: IronMQ::Queues
- Inherits:
-
Object
- Object
- IronMQ::Queues
- Defined in:
- lib/iron_mq/queues.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #clear(options = {}) ⇒ Object
- #delete(options = {}) ⇒ Object
-
#get(options = {}) ⇒ Object
options: :name => can specify an alternative queue name.
-
#initialize(client) ⇒ Queues
constructor
A new instance of Queues.
- #list(options = {}) ⇒ Object
- #path(options = {}) ⇒ Object
-
#post(options = {}) ⇒ Object
Update a queue options: :name => if not specified, will use global queue name :subscribers => url’s to subscribe to :push_type => multicast (default) or unicast.
Constructor Details
#initialize(client) ⇒ Queues
Returns a new instance of Queues.
9 10 11 |
# File 'lib/iron_mq/queues.rb', line 9 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/iron_mq/queues.rb', line 7 def client @client end |
Class Method Details
.path(options) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/iron_mq/queues.rb', line 13 def self.path() path = "projects/#{[:project_id]}/queues" name = [:name] || [:queue_name] || ['queue_name'] if name path << "/#{CGI::escape(name)}" end path end |
Instance Method Details
#clear(options = {}) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/iron_mq/queues.rb', line 40 def clear(={}) @client.logger.debug "Clearing queue #{[:name]}" r1 = @client.post("#{path()}/clear", ) @client.logger.debug "Clear result: #{r1}" r1 end |
#delete(options = {}) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/iron_mq/queues.rb', line 47 def delete(={}) @client.logger.debug "Deleting queue #{[:name]}" r1 = @client.delete("#{path()}", ) @client.logger.debug "Delete result: #{r1}" r1 end |
#get(options = {}) ⇒ Object
options:
:name => can specify an alternative queue name
56 57 58 59 60 61 62 63 |
# File 'lib/iron_mq/queues.rb', line 56 def get(={}) [:name] ||= @client.queue_name r = @client.get("#{path()}") #puts "HEADERS" #p r.headers res = @client.parse_response(r) return Queue.new(@client, res) end |
#list(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/iron_mq/queues.rb', line 27 def list(={}) ret = [] r1 = @client.get("#{path()}", ) #p r1 res = @client.parse_response(r1) res.each do |q| #p q q = Queue.new(@client, q) ret << q end ret end |
#path(options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/iron_mq/queues.rb', line 22 def path(={}) [:project_id] = @client.project_id Queues.path() end |
#post(options = {}) ⇒ Object
Update a queue options:
:name => if not specified, will use global queue name
:subscribers => url's to subscribe to
:push_type => multicast (default) or unicast.
70 71 72 73 74 75 |
# File 'lib/iron_mq/queues.rb', line 70 def post(={}) [:name] ||= @client.queue_name res = @client.parse_response(@client.post(path(), )) #p res res end |