Class: Twing::Queue
- Inherits:
-
Object
- Object
- Twing::Queue
- Defined in:
- lib/twing/queue.rb
Instance Method Summary collapse
-
#initialize(name, namespace) ⇒ Queue
constructor
A new instance of Queue.
- #process ⇒ Object
- #push(data) ⇒ Object
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
#process ⇒ Object
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 |