Class: Logbert::Consumers::RedisConsumer
- Inherits:
-
Object
- Object
- Logbert::Consumers::RedisConsumer
- Defined in:
- lib/logbert/consumers/redis_consumer.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
Returns the value of attribute handlers.
-
#key ⇒ Object
Returns the value of attribute key.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize(redis_connection, key, options = {}) ⇒ RedisConsumer
constructor
A new instance of RedisConsumer.
- #work ⇒ Object
Constructor Details
#initialize(redis_connection, key, options = {}) ⇒ RedisConsumer
Returns a new instance of RedisConsumer.
12 13 14 15 16 |
# File 'lib/logbert/consumers/redis_consumer.rb', line 12 def initialize(redis_connection, key, = {}) @redis = redis_connection @key = key @handlers = .fetch(:handlers, []) end |
Instance Attribute Details
#handlers ⇒ Object
Returns the value of attribute handlers.
10 11 12 |
# File 'lib/logbert/consumers/redis_consumer.rb', line 10 def handlers @handlers end |
#key ⇒ Object
Returns the value of attribute key.
10 11 12 |
# File 'lib/logbert/consumers/redis_consumer.rb', line 10 def key @key end |
#redis ⇒ Object
Returns the value of attribute redis.
10 11 12 |
# File 'lib/logbert/consumers/redis_consumer.rb', line 10 def redis @redis end |
Instance Method Details
#work ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/logbert/consumers/redis_consumer.rb', line 18 def work # Blocking loop to read serialized messages of the redis queue loop do msg = redis.brpop(key) # blocking list pop primitive @handlers.each do |h| m = Message.from_json(msg) h.(m) end end end |