Class: Fluent::BacklogOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_backlog_create.rb

Instance Method Summary collapse

Constructor Details

#initializeBacklogOutput

Returns a new instance of BacklogOutput.



16
17
18
19
# File 'lib/fluent/plugin/out_backlog_create.rb', line 16

def initialize
  super
  require 'xmlrpc/client'
end

Instance Method Details

#configure(conf) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/fluent/plugin/out_backlog_create.rb', line 21

def configure(conf)
  super
  @server = XMLRPC::Client.new2("https://#{@user}:#{@password}@#{@space}.backlog.jp/XML-RPC")
  @summary_keys = @summary_keys.split(',')
  if @description_keys
    @description_keys = @description_keys.split(',')
  end
end

#format(tag, time, record) ⇒ Object



38
39
40
# File 'lib/fluent/plugin/out_backlog_create.rb', line 38

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#shutdownObject



34
35
36
# File 'lib/fluent/plugin/out_backlog_create.rb', line 34

def shutdown
  super
end

#startObject



30
31
32
# File 'lib/fluent/plugin/out_backlog_create.rb', line 30

def start
  super
end

#write(chunk) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_backlog_create.rb', line 42

def write(chunk)
  chunk.msgpack_each do |tag, time, record|
    summary = @summary_template % @summary_keys.map { |key| record[key] }
    args = { projectId: @project_id, summary: summary }
    if @description_template
      description = @description_template % @description_keys.map { |key| record[key] }
      args[:description] = description
    end
    args[:component] = @component if @component
    @server.call('backlog.createIssue', args)
  end
end