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.
      33 34 35 36 37 38  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 33 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) ⇒ Object
      58 59 60  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 58 def format(tag, time, record) [time, record].to_msgpack end  | 
  
#formatted_to_msgpack_binary? ⇒ Boolean
      54 55 56  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 54 def formatted_to_msgpack_binary? true end  | 
  
#generate_message(args = {}) ⇒ Object
      86 87 88 89 90 91 92  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 86 def (args={}) time = args[:time] record = args[:record] tag = args[:tag] ERB.new(@message).result(binding).gsub("\\n", "\n") end  | 
  
#post_message(args = {}) ⇒ Object
      80 81 82 83 84  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 80 def (args={}) body = (args) ChatWork.api_key = @api_token ChatWork::Message.create(room_id: @room_id, body: body) end  | 
  
#prefer_buffered_processing ⇒ Object
      50 51 52  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 50 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.
      67 68 69 70 71  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 67 def process(tag, es) es.each {|time,record| (time: time, record: record, tag: tag) } end  | 
  
#shutdown ⇒ Object
This method is called when shutting down.
      46 47 48  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 46 def shutdown super end  | 
  
#start ⇒ Object
This method is called when starting.
      41 42 43  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 41 def start super end  | 
  
#write(chunk) ⇒ Object
      73 74 75 76 77 78  | 
    
      # File 'lib/fluent/plugin/out_chatwork.rb', line 73 def write(chunk) tag = chunk..tag chunk.msgpack_each {|time, record| (time: time, record: record, tag: tag) } end  |