Class: DataLogger::Sinks::RedisPubSub
- Inherits:
-
Object
- Object
- DataLogger::Sinks::RedisPubSub
- Defined in:
- lib/datalogger/sinks/redis/pubsub.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ RedisPubSub
constructor
A new instance of RedisPubSub.
- #log(component, data) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ RedisPubSub
Returns a new instance of RedisPubSub.
8 9 10 11 12 13 |
# File 'lib/datalogger/sinks/redis/pubsub.rb', line 8 def initialize(opts={}) redis_url = opts[:redis_url] || "redis://localhost:6379" uri = URI.parse(redis_url) @redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) @channel = opts[:channel] || 'logs' end |
Instance Method Details
#log(component, data) ⇒ Object
15 16 17 |
# File 'lib/datalogger/sinks/redis/pubsub.rb', line 15 def log(component, data) @redis.publish @channel, data.merge(component: component).to_json end |