Class: Woodchuck::Output::Redis

Inherits:
Woodchuck::Output show all
Defined in:
lib/woodchuck/output/redis.rb

Instance Attribute Summary collapse

Attributes inherited from Woodchuck::Output

#logger, #type

Instance Method Summary collapse

Constructor Details

#initializeRedis

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

#dbObject

Returns the value of attribute db.



5
6
7
# File 'lib/woodchuck/output/redis.rb', line 5

def db
  @db
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/woodchuck/output/redis.rb', line 5

def host
  @host
end

#namespaceObject

Returns the value of attribute namespace.



5
6
7
# File 'lib/woodchuck/output/redis.rb', line 5

def namespace
  @namespace
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/woodchuck/output/redis.rb', line 5

def port
  @port
end

#urlObject

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

#redisObject



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