class RedisLogstash::Socket
Attributes
options[RW]
redis[RW]
redis_key[RW]
Public Class Methods
get()
click to toggle source
# File lib/redis_logstash/socket.rb, line 9 def get @@socket ||= new end
new()
click to toggle source
# File lib/redis_logstash/socket.rb, line 19 def initialize self.options = ParseConfig.get[:redis] host = options[:host] || '127.0.0.1' port = options[:port] || 6379 password = options[:password] || nil self.redis_key = options[:key] || 'logstash' self.redis = password ? ::Redis.new(host: host, port: port, password: password) : ::Redis.new(host: host, port: port) end
write(json)
click to toggle source
# File lib/redis_logstash/socket.rb, line 13 def write(json) get.push(json) end
Public Instance Methods
push(json)
click to toggle source
# File lib/redis_logstash/socket.rb, line 31 def push(json) begin unless redis.rpush(redis_key, Logger.gzip({type: options[:type], logs: json.to_json}.to_json)) raise "could not send event to redis" end rescue ::Redis::InheritedError redis.client.connect retry end end