fluent-plugin-mysql-appender 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06cdb575e833edb1b752b8b21f22305c47f6ce66
4
- data.tar.gz: 480964a2ecd5ed0bed3dfc317a47ecb2ef06671a
3
+ metadata.gz: 9bea290735b18887dd55d09efceaa35bc43b0193
4
+ data.tar.gz: 18d31c5eaea15dbeea7c3e4b95f78ac1ec63fbc7
5
5
  SHA512:
6
- metadata.gz: 00599555ae75841c444bde00b3272cc06ffd7c69cb7e7937e06211edefd8101c4d069ba43d575ace8e4793858faeb3497535bcd2ee44a93d1e2acf393ea3eaf1
7
- data.tar.gz: 48e844a6a9078b6482a6a3859197e370b19beb1f651dfa3d69f531e9fc61dc01a7a3fae5219795cdfb44dc7a0d988edfcfeaeeebac3e18e1c9419aec32d6519e
6
+ metadata.gz: 4fa61e94df8ce4ba988f60d56a2284230933e49feaf8f3fe17945aca4f19d250aaf226f3f6b5870b543e923bc5d6eefaf4ea5d9080ca74aec3b6a31c3d33c899
7
+ data.tar.gz: 5c6ff76d81458910aac3b0fa1df2376f276008360126dcb024476a1a3fcca46615dbdfc8dc625dc616185b012261ffb3553f99fdedbd04d626201999d8bea154
@@ -50,6 +50,7 @@ Sample "in_tables.yml" is below.
50
50
  - column1
51
51
  - column2
52
52
  last_id: -1
53
+ buffer: 10 # last 10 records don't append (default 0).
53
54
  td_database: sample_datasets
54
55
 
55
56
  - table_name: test_tbl2
@@ -61,5 +62,6 @@ Sample "in_tables.yml" is below.
61
62
  - column1
62
63
  - column2
63
64
  last_id: -1
65
+ buffer: 10 # last 10 records don't append (default 0).
64
66
  td_database: sample_datasets
65
67
  ```
@@ -25,6 +25,7 @@ It is a guide to replicate single mysql table to treasure data.
25
25
  time_column created_at # specify TIME column.
26
26
  limit 1000 # query limit
27
27
  last_id -1 # specify primary_key start
28
+ buffer 10 # last 10 records don't append (default 0).
28
29
  </source>
29
30
 
30
31
  <match appender.*.*>
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "fluent-plugin-mysql-appender"
4
- spec.version = "0.3.2"
4
+ spec.version = "0.3.3"
5
5
  spec.authors = ["TERASAKI Tsuyoshi"]
6
6
  spec.email = ["tsuyoshi_terasaki@realworld.jp"]
7
7
 
@@ -26,6 +26,7 @@ module Fluent
26
26
  config_param :primary_key, :string, :default => 'id'
27
27
  config_param :interval, :string, :default => '1m'
28
28
  config_param :tag, :string, :default => nil
29
+ config_param :buffer, :integer, :defalut => 0
29
30
 
30
31
  def configure(conf)
31
32
  super
@@ -63,22 +64,27 @@ module Fluent
63
64
  start_time = Time.now
64
65
  select_query = @query.gsub(/"/,'') + " where #{primary_key} > #{last_id} order by #{primary_key} asc limit #{limit}"
65
66
  rows, con = query(select_query, con)
66
- rows.each_with_index do |row, index|
67
- tag = format_tag(@tag, {:event => :insert})
68
- if @time_column.nil? then
69
- td_time = Engine.now
70
- else
71
- if row[@time_column].kind_of?(Time) then
72
- td_time = row[@time_column].to_i
73
- else
74
- td_time = Time.parse(row[@time_column].to_s).to_i
75
- end
67
+ if @buffer < rows.size then
68
+ if index == (rows.size - @buffer) then
69
+ break
76
70
  end
77
- row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
78
- router.emit(tag, td_time, row)
79
- rows_count += 1
80
- if index == rows.size - 1
81
- @last_id = row[@primary_key]
71
+ rows.each_with_index do |row, index|
72
+ tag = format_tag(@tag, {:event => :insert})
73
+ if @time_column.nil? then
74
+ td_time = Engine.now
75
+ else
76
+ if row[@time_column].kind_of?(Time) then
77
+ td_time = row[@time_column].to_i
78
+ else
79
+ td_time = Time.parse(row[@time_column].to_s).to_i
80
+ end
81
+ end
82
+ row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
83
+ router.emit(tag, td_time, row)
84
+ rows_count += 1
85
+ if index == rows.size - @buffer - 1
86
+ @last_id = row[@primary_key]
87
+ end
82
88
  end
83
89
  end
84
90
  con.close
@@ -29,11 +29,11 @@ module Fluent
29
29
  @interval = Config.time_value(@interval)
30
30
 
31
31
  if @yaml_path.nil?
32
- raise Fluent::ConfigError, "mysql_appender_multi: missing 'yaml_path' parameter or file not found."
32
+ raise Fluent::ConfigError, "mysql_appender_multi: missing 'yaml_path' parameter."
33
33
  end
34
34
 
35
35
  if !File.exist?(@yaml_path)
36
- raise Fluent::ConfigError, "mysql_appender_multi: 'yaml_path' No such file."
36
+ raise Fluent::ConfigError, "mysql_appender_multi: No such file in 'yaml_path'."
37
37
  end
38
38
 
39
39
  if @tag.nil?
@@ -66,6 +66,7 @@ module Fluent
66
66
  def poll(config)
67
67
  begin
68
68
  tag = format_tag(config)
69
+ buffer = config['buffer'] || 0
69
70
  @mutex.synchronize {
70
71
  $log.info "mysql_replicator_multi: polling start. :tag=>#{tag}"
71
72
  }
@@ -75,21 +76,26 @@ module Fluent
75
76
  rows_count = 0
76
77
  start_time = Time.now
77
78
  rows, con = query(get_query(config, last_id), con)
78
- rows.each_with_index do |row, index|
79
- if config['time_column'].nil? then
80
- td_time = Engine.now
81
- else
82
- if row[config['time_column']].kind_of?(Time) then
83
- td_time = row[config['time_column']].to_i
84
- else
85
- td_time = Time.parse(row[config['time_column']].to_s).to_i
86
- end
87
- end
88
- row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
89
- router.emit(tag, td_time, row)
90
- rows_count += 1
91
- if index == rows.size - 1
92
- last_id = row[config['primary_key']]
79
+ if buffer < rows.size then
80
+ rows.each_with_index do |row, index|
81
+ if index == (rows.size - buffer) then
82
+ break
83
+ end
84
+ if config['time_column'].nil? then
85
+ td_time = Engine.now
86
+ else
87
+ if row[config['time_column']].kind_of?(Time) then
88
+ td_time = row[config['time_column']].to_i
89
+ else
90
+ td_time = Time.parse(row[config['time_column']].to_s).to_i
91
+ end
92
+ end
93
+ row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
94
+ router.emit(tag, td_time, row)
95
+ rows_count += 1
96
+ if index == (rows.size - buffer - 1)
97
+ last_id = row[config['primary_key']]
98
+ end
93
99
  end
94
100
  end
95
101
  con.close
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TERASAKI Tsuyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-17 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd