Class: DataLogger::Sinks::RedisList

Inherits:
Object
  • Object
show all
Defined in:
lib/datalogger/sinks/redis/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RedisList

Returns a new instance of RedisList.



8
9
10
11
12
13
# File 'lib/datalogger/sinks/redis/list.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)
  @list = opts[:list] || 'logs'
end

Instance Method Details

#log(component, data) ⇒ Object



15
16
17
# File 'lib/datalogger/sinks/redis/list.rb', line 15

def log(component, data)
  @redis.rpush @list, data.merge(component: component).to_json  
end