Class: Woodchuck::Output::Redis
- Inherits:
-
Woodchuck::Output
- Object
- Woodchuck::Output
- Woodchuck::Output::Redis
- Defined in:
- lib/woodchuck/output/redis.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#host ⇒ Object
Returns the value of attribute host.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#port ⇒ Object
Returns the value of attribute port.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from Woodchuck::Output
Instance Method Summary collapse
- #handle(event) ⇒ Object
-
#initialize ⇒ Redis
constructor
A new instance of Redis.
- #redis ⇒ Object
Constructor Details
#initialize ⇒ Redis
Returns a new instance of Redis.
7 8 9 10 11 12 |
# File 'lib/woodchuck/output/redis.rb', line 7 def initialize super @type = :redis @url = Addressable::URI.parse(ENV['REDIS_URL'] || 'redis://localhost:6379/9') @namespace = ENV['REDIS_NAMESPACE'] || 'logstash:woodchuck' end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
5 6 7 |
# File 'lib/woodchuck/output/redis.rb', line 5 def db @db end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/woodchuck/output/redis.rb', line 5 def host @host end |
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/woodchuck/output/redis.rb', line 5 def namespace @namespace end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/woodchuck/output/redis.rb', line 5 def port @port end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/woodchuck/output/redis.rb', line 5 def url @url end |
Instance Method Details
#handle(event) ⇒ Object
19 20 21 22 |
# File 'lib/woodchuck/output/redis.rb', line 19 def handle(event) redis.lpush("events", event.to_json) @logger.info "Logging event to Redis", event.to_hash end |
#redis ⇒ Object
14 15 16 17 |
# File 'lib/woodchuck/output/redis.rb', line 14 def redis client = ::Redis.new(:url => url) ::Redis::Namespace.new(namespace, :redis => client) end |