Class: FanSQS::QueueWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/FanSQS/queue_wrapper.rb

Class Method Summary collapse

Class Method Details

.cacheObject



17
18
19
# File 'lib/FanSQS/queue_wrapper.rb', line 17

def cache
  @cache
end

.create_new(name) ⇒ Object



13
14
15
# File 'lib/FanSQS/queue_wrapper.rb', line 13

def create_new(name)
  AWS.sqs.queues.create(name.to_s)
end

.exists?(qname) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/FanSQS/queue_wrapper.rb', line 21

def exists?(qname)
  if @cache[qname]
    return @cache[qname]
  else
    return @cache[qname] = AWS.sqs.queues.named(formatted_queue_name(qname)) while @cache[qname] == nil
  end
rescue AWS::SQS::Errors::NonExistentQueue
  return false
end

.instantiate(qname) ⇒ Object

Find out if the queue exists. If it does not exist, create a new one This line below has a high chance of causing confusion as it will try to use either FanSQS::Queue or AWS::SQS::Queue. Maybe use the class from AWS gem instead?



8
9
10
11
# File 'lib/FanSQS/queue_wrapper.rb', line 8

def instantiate(qname)
  name = formatted_queue_name(qname)
  exists?(name) || create_new(name)
end