Class: Twing::Queue

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

Instance Method Summary collapse

Constructor Details

#initialize(name, namespace) ⇒ Queue

Returns a new instance of Queue.



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

def initialize(name, namespace)
  @name = name
  @redis = Redis.current
end

Instance Method Details

#processObject



12
13
14
15
16
17
# File 'lib/twing/queue.rb', line 12

def process
  loop do
    key, msg = @redis.blpop(@name, 0)
    yield msg if msg
  end
end

#push(data) ⇒ Object



8
9
10
# File 'lib/twing/queue.rb', line 8

def push(data)
  @redis.rpush(@name, data)
end