Class: Octokiq::Connection
- Inherits:
-
Object
- Object
- Octokiq::Connection
- Defined in:
- lib/octokiq/connection.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
- #fetch(queues) ⇒ Object
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #push(queue, data) ⇒ Object
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
8 9 10 |
# File 'lib/octokiq/connection.rb', line 8 def initialize @redis = Redis.new end |
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
6 7 8 |
# File 'lib/octokiq/connection.rb', line 6 def redis @redis end |
Instance Method Details
#fetch(queues) ⇒ Object
12 13 14 15 |
# File 'lib/octokiq/connection.rb', line 12 def fetch(queues) _, job = redis.blpop(*build_queues(queues), 0) JSON.parse(job) end |
#push(queue, data) ⇒ Object
17 18 19 |
# File 'lib/octokiq/connection.rb', line 17 def push(queue, data) redis.rpush(build_queue(queue), data.to_json) end |