Class: LogStasher::Device::Redis
- Inherits:
-
Object
- Object
- LogStasher::Device::Redis
- Defined in:
- lib/logstasher/device/redis.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #close ⇒ Object
- #data_type ⇒ Object
-
#initialize(options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #key ⇒ Object
- #redis_options ⇒ Object
- #write(log) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
8 9 10 11 12 |
# File 'lib/logstasher/device/redis.rb', line 8 def initialize( = {}) @options = .merge() configure_redis end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/logstasher/device/redis.rb', line 6 def @options end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
6 7 8 |
# File 'lib/logstasher/device/redis.rb', line 6 def redis @redis end |
Instance Method Details
#close ⇒ Object
42 43 44 |
# File 'lib/logstasher/device/redis.rb', line 42 def close redis.quit end |
#data_type ⇒ Object
14 15 16 |
# File 'lib/logstasher/device/redis.rb', line 14 def data_type [:data_type] end |
#key ⇒ Object
18 19 20 |
# File 'lib/logstasher/device/redis.rb', line 18 def key [:key] end |
#redis_options ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/logstasher/device/redis.rb', line 22 def unless @redis_options default_keys = .keys @redis_options = .select { |k, _v| !default_keys.include?(k) } end @redis_options end |
#write(log) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/logstasher/device/redis.rb', line 31 def write(log) case data_type when 'list' redis.rpush(key, log) when 'channel' redis.publish(key, log) else raise "Unknown data type #{data_type}" end end |