Class: Fluent::Plugin::RedisPubOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::RedisPubOutput
- Defined in:
- lib/fluent/plugin/out_redis_pub.rb
Constant Summary collapse
- DEFAULT_BUFFER_TYPE =
"memory"
Instance Attribute Summary collapse
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #formatted_to_msgpack_binary ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
30 31 32 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 30 def redis @redis end |
Instance Method Details
#configure(conf) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 45 def configure(conf) compat_parameters_convert(conf, :buffer, :inject) super raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag raise Fluent::ConfigError, "'time' in chunk_keys is required." if not @chunk_key_time @unpacker = Fluent::Engine.msgpack_factory.unpacker end |
#format(tag, time, record) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 73 def format(tag, time, record) record = inject_values_to_record(tag, time, record) log = { :tag => tag, :time => time, :record => record } log.to_msgpack end |
#formatted_to_msgpack_binary ⇒ Object
83 84 85 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 83 def formatted_to_msgpack_binary true end |
#shutdown ⇒ Object
68 69 70 71 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 68 def shutdown @redis.quit super end |
#start ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 54 def start super = { host: @host, port: @port, thread_safe: true, db: @db_number } [:password] = @password if @password @redis = Redis.new() end |
#write(chunk) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/fluent/plugin/out_redis_pub.rb', line 87 def write(chunk) @redis.pipelined do chunk.msgpack_each do |record| @redis.publish @channel, record.to_json end end end |