fluent-plugin-mysql-appender 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f21781c970449bb44a1aab51ea2ed1078a6c7fb9
4
- data.tar.gz: 8c4e17ccd6b87360897f067a506ad92d7b81ea47
3
+ metadata.gz: ca968bd1cfa4b493d5175521b3ed90422d2aeb33
4
+ data.tar.gz: 1bc085367f4a27ac9b1c5b9196f232f6be031fe8
5
5
  SHA512:
6
- metadata.gz: 3925652f1b00a0958682aa71f66404560bd36af4298511a8d460eb1dd67d957fc9a4f79cba5db62658decf1d89d0092186d38ee4a1a61c1ad2e213008fc58b08
7
- data.tar.gz: df0b83ad3bd612549e0b825e7c20c0fc34546a7fe0c6dae5c1a1ac1c58185f88b78d71695ee31623ea47349d1e387457b7083fa26cb89fe9791c6946d9597802
6
+ metadata.gz: 3da542d0fd2f0e93929cb6f9490bf438093bcfe05c3cfbb20b61c5d24ada44dccc3f8856e033de62a40e4997038f20b473511dcf3e29322ab73d05790ea7a6ad
7
+ data.tar.gz: 159468925304ee7b688c068c004ac105cd06e8b0bb2d9f108a0bb1c0ae0decf9d3be5535a5c55fade50d95b99e8595476281dd5b63455ecbe4f46aee74618acb
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "fluent-plugin-mysql-appender"
4
- spec.version = "0.1.3"
5
- spec.authors = ["tsuyoshi_terasaki"]
4
+ spec.version = "0.1.4"
5
+ spec.authors = ["TERASAKI Tsuyoshi"]
6
6
  spec.email = ["tsuyoshi_terasaki@realworld.jp"]
7
7
 
8
- spec.summary = %q{Fluentd input plugin to track insert event from MySQL database server.}
8
+ spec.summary = %q{Fluentd input plugin to insert from MySQL database server.}
9
9
  spec.description = %q{Simple incremental id's insert.}
10
10
  spec.homepage = "https://github.com/rw-hub/fluent-plugin-mysql-appender"
11
11
  spec.license = "MIT"
@@ -18,7 +18,10 @@ module Fluent
18
18
  config_param :password, :string, :default => nil, :secret => true
19
19
  config_param :database, :string, :default => nil
20
20
  config_param :encoding, :string, :default => 'utf8'
21
+ config_param :last_id, :integer, :default => -1
22
+ config_param :limit, :integer, :default => 100
21
23
  config_param :query, :string
24
+ config_param :time_column, :string, :default => nil
22
25
  config_param :primary_key, :string, :default => 'id'
23
26
  config_param :interval, :string, :default => '1m'
24
27
  config_param :tag, :string, :default => nil
@@ -31,7 +34,7 @@ module Fluent
31
34
  raise Fluent::ConfigError, "mysql_appender: missing 'tag' parameter. Please add following line into config like 'tag replicator.mydatabase.mytable.${event}.${primary_key}'"
32
35
  end
33
36
 
34
- $log.info "adding mysql_appender worker. :tag=>#{tag} :query=>#{@query} :prepared_query=>#{@prepared_query} :interval=>#{@interval}sec"
37
+ $log.info "adding mysql_appender worker. :tag=>#{tag} :query=>#{@query} :limit=>#{limit} :interval=>#{@interval} sec "
35
38
  end
36
39
 
37
40
  def start
@@ -54,28 +57,28 @@ module Fluent
54
57
 
55
58
  def poll
56
59
  con = get_connection()
57
- max_id = -1
58
60
  loop do
59
61
  rows_count = 0
60
62
  start_time = Time.now
61
- if max_id == -1
62
- select_query = @query.gsub(/"/,'') + " order by #{primary_key} asc"
63
- else
64
- select_query = @query.gsub(/"/,'') + " where #{primary_key} > #{max_id} order by #{primary_key} asc"
65
- end
63
+ select_query = @query.gsub(/"/,'') + " where #{primary_key} > #{last_id} order by #{primary_key} asc limit #{limit}"
66
64
  rows, con = query(select_query, con)
67
65
  rows.each_with_index do |row, index|
68
66
  tag = format_tag(@tag, {:event => :insert})
67
+ if @time_column.nil? then
68
+ td_time = Engine.now
69
+ else
70
+ td_time = Time.parse(row[@time_column]).to_i
71
+ end
69
72
  row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
70
- router.emit(tag, Engine.now, row)
73
+ router.emit(tag, td_time, row)
71
74
  rows_count += 1
72
75
  if index == rows.size - 1
73
- max_id = row[@primary_key]
76
+ @last_id = row[@primary_key]
74
77
  end
75
78
  end
76
79
  con.close
77
80
  elapsed_time = sprintf("%0.02f", Time.now - start_time)
78
- $log.info "mysql_appender: finished execution :tag=>#{tag} :rows_count=>#{rows_count} :elapsed_time=>#{elapsed_time} sec"
81
+ $log.info "mysql_appender: finished execution :tag=>#{tag} :rows_count=>#{rows_count} :last_id=>#{last_id} :elapsed_time=>#{elapsed_time} sec"
79
82
  sleep @interval
80
83
  end
81
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mysql-appender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
- - tsuyoshi_terasaki
7
+ - TERASAKI Tsuyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -120,7 +120,7 @@ rubyforge_project:
120
120
  rubygems_version: 2.5.1
121
121
  signing_key:
122
122
  specification_version: 4
123
- summary: Fluentd input plugin to track insert event from MySQL database server.
123
+ summary: Fluentd input plugin to insert from MySQL database server.
124
124
  test_files:
125
125
  - test/fluent/plugin/in_mysql_appender_test.rb
126
126
  - test/test_helper.rb