Class: Fluent::Plugin::ChatworkOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::ChatworkOutput
- Defined in:
- lib/fluent/plugin/out_chatwork.rb
Constant Summary collapse
- DEFAULT_BUFFER_TYPE =
"memory"
Instance Method Summary collapse
-
#configure(conf) ⇒ Object
This method is called before starting.
- #format(tag, time, record) ⇒ Object
- #formatted_to_msgpack_binary? ⇒ Boolean
- #generate_message(args = {}) ⇒ Object
- #post_message(args = {}) ⇒ Object
- #prefer_buffered_processing ⇒ Object
-
#process(tag, es) ⇒ Object
This method is called when an event reaches Fluentd.
-
#shutdown ⇒ Object
This method is called when shutting down.
-
#start ⇒ Object
This method is called when starting.
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
This method is called before starting.
27 28 29 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 27 def configure(conf) super end |
#format(tag, time, record) ⇒ Object
49 50 51 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 49 def format(tag, time, record) [time, record].to_msgpack end |
#formatted_to_msgpack_binary? ⇒ Boolean
45 46 47 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 45 def formatted_to_msgpack_binary? true end |
#generate_message(args = {}) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 77 def (args={}) time = args[:time] record = args[:record] tag = args[:tag] ERB.new().result(binding).gsub("\\n", "\n") end |
#post_message(args = {}) ⇒ Object
71 72 73 74 75 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 71 def (args={}) body = (args) ChatWork.api_key = @api_token ChatWork::Message.create(room_id: @room_id, body: body) end |
#prefer_buffered_processing ⇒ Object
41 42 43 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 41 def prefer_buffered_processing @buffered end |
#process(tag, es) ⇒ Object
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.
58 59 60 61 62 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 58 def process(tag, es) es.each {|time,record| (time: time, record: record, tag: tag) } end |
#shutdown ⇒ Object
This method is called when shutting down.
37 38 39 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 37 def shutdown super end |
#start ⇒ Object
This method is called when starting.
32 33 34 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 32 def start super end |
#write(chunk) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/fluent/plugin/out_chatwork.rb', line 64 def write(chunk) tag = chunk..tag chunk.msgpack_each {|time, record| (time: time, record: record, tag: tag) } end |