Class: LogstashRails::Transport::Redis
- Inherits:
-
LogstashRails::TransportBase
- Object
- LogstashRails::TransportBase
- LogstashRails::Transport::Redis
- Defined in:
- lib/logstash_rails/transport/redis.rb
Instance Method Summary collapse
-
#initialize(formatter, options) ⇒ Redis
constructor
A new instance of Redis.
- #push(json_event) ⇒ Object
Methods inherited from LogstashRails::TransportBase
Constructor Details
#initialize(formatter, options) ⇒ Redis
Returns a new instance of Redis.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/logstash_rails/transport/redis.rb', line 13 def initialize(formatter, ) host = [:host] || '127.0.0.1' port = [:port] || 6379 redis_key = [:redis_key] || 'logstash' @redis = ::Redis.new(host: host, port: port) @redis_key = redis_key super end |
Instance Method Details
#push(json_event) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/logstash_rails/transport/redis.rb', line 24 def push(json_event) begin unless @redis.rpush(@redis_key, json_event) raise "could not send event to redis" end rescue ::Redis::InheritedError @redis.client.connect retry end end |