class Fluent::Plugin::ChatworkOutput
Constants
- DEFAULT_BUFFER_TYPE
Public Instance Methods
configure(conf)
click to toggle source
This method is called before starting.
Calls superclass method
# File lib/fluent/plugin/out_chatwork.rb, line 32 def configure(conf) compat_parameters_convert(conf, :buffer) super raise Fluent::ConfigError, "'tag' in chunk_keys is required." unless @chunk_key_tag end
format(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 57 def format(tag, time, record) [time, record].to_msgpack end
formatted_to_msgpack_binary?()
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 53 def formatted_to_msgpack_binary? true end
generate_message(args={})
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 85 def generate_message(args={}) time = args[:time] record = args[:record] tag = args[:tag] ERB.new(@message).result(binding).gsub("\\n", "\n") end
post_message(args={})
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 79 def post_message(args={}) body = generate_message(args) ChatWork.api_key = @api_token ChatWork::Message.create(room_id: @room_id, body: body) end
prefer_buffered_processing()
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 49 def prefer_buffered_processing @buffered end
process(tag, es)
click to toggle source
This method is called when an event reaches Fluentd. ‘es’ is a Fluent::EventStream object that includes multiple events. You can use ‘es.each {|time,record| … }’ to retrieve events. ‘chain’ is an object that manages transactions. Call ‘chain.next’ at appropriate points and rollback if it raises an exception.
# File lib/fluent/plugin/out_chatwork.rb, line 66 def process(tag, es) es.each {|time,record| post_message(time: time, record: record, tag: tag) } end
shutdown()
click to toggle source
This method is called when shutting down.
Calls superclass method
# File lib/fluent/plugin/out_chatwork.rb, line 45 def shutdown super end
start()
click to toggle source
This method is called when starting.
Calls superclass method
# File lib/fluent/plugin/out_chatwork.rb, line 40 def start super end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_chatwork.rb, line 72 def write(chunk) tag = chunk.metadata.tag chunk.msgpack_each {|time, record| post_message(time: time, record: record, tag: tag) } end