fluent-plugin-mysql-replicator 0.2.1 → 0.2.2
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.
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "fluent-plugin-mysql-replicator"
|
4
|
-
s.version = "0.2.
|
4
|
+
s.version = "0.2.2"
|
5
5
|
s.authors = ["Kentaro Yoshida"]
|
6
6
|
s.email = ["y.ken.studio@gmail.com"]
|
7
7
|
s.homepage = "https://github.com/y-ken/fluent-plugin-mysql-replicator"
|
@@ -59,7 +59,11 @@ module Fluent
|
|
59
59
|
query(@query).each do |row|
|
60
60
|
current_ids << row[@primary_key]
|
61
61
|
current_hash = Digest::SHA1.hexdigest(row.flatten.join)
|
62
|
-
row.each {|k, v| row[k] = v.to_s if v.is_a?
|
62
|
+
row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date)}
|
63
|
+
if row[@primary_key].nil?
|
64
|
+
$log.error "mysql_replicator: missing primary_key. :tag=>#{tag} :primary_key=>#{primary_key}"
|
65
|
+
break
|
66
|
+
end
|
63
67
|
if !table_hash.include?(row[@primary_key])
|
64
68
|
tag = format_tag(@tag, {:event => :insert})
|
65
69
|
emit_record(tag, row)
|
@@ -84,7 +88,7 @@ module Fluent
|
|
84
88
|
end
|
85
89
|
end
|
86
90
|
end
|
87
|
-
elapsed_time = sprintf("%0.02f",
|
91
|
+
elapsed_time = sprintf("%0.02f", Time.now - start_time)
|
88
92
|
$log.info "mysql_replicator: finished execution :tag=>#{tag} :elapsed_time=>#{elapsed_time} seconds"
|
89
93
|
sleep @interval
|
90
94
|
end
|
@@ -97,7 +101,7 @@ module Fluent
|
|
97
101
|
def format_tag(tag, param)
|
98
102
|
pattern = {'${event}' => param[:event].to_s, '${primary_key}' => @primary_key}
|
99
103
|
tag.gsub(/\${[a-z_]+(\[[0-9]+\])?}/, pattern) do
|
100
|
-
$log.warn "mysql_replicator: missing placeholder. tag
|
104
|
+
$log.warn "mysql_replicator: missing placeholder. :tag=>#{tag} :placeholder=>#{$1}" unless pattern.include?($1)
|
101
105
|
pattern[$1]
|
102
106
|
end
|
103
107
|
end
|
@@ -69,15 +69,20 @@ module Fluent
|
|
69
69
|
db = get_origin_connection(config)
|
70
70
|
db.query(config['query']).each do |row|
|
71
71
|
@mutex.lock
|
72
|
-
row.each {|k, v| row[k] = v.to_s if v.is_a?
|
72
|
+
row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date)}
|
73
73
|
current_id = row[primary_key]
|
74
|
+
if row[primary_key].nil?
|
75
|
+
$log.error "mysql_replicator_multi: missing primary_key. :setting_name=>#{config['name']} :primary_key=>#{primary_key}"
|
76
|
+
@mutex.unlock
|
77
|
+
break
|
78
|
+
end
|
74
79
|
detect_insert_update(config, row)
|
75
80
|
detect_delete(config, current_id, previous_id)
|
76
81
|
previous_id = current_id
|
77
82
|
@mutex.unlock
|
78
83
|
end
|
79
84
|
db.close
|
80
|
-
elapsed_time = sprintf("%0.02f",
|
85
|
+
elapsed_time = sprintf("%0.02f", Time.now - start_time)
|
81
86
|
$log.info "mysql_replicator_multi: finished execution :setting_name=>#{config['name']} :elapsed_time=>#{elapsed_time} seconds"
|
82
87
|
sleep config['interval']
|
83
88
|
end
|
@@ -170,7 +175,7 @@ module Fluent
|
|
170
175
|
def format_tag(tag, param)
|
171
176
|
pattern = {'${name}' => param[:name], '${event}' => param[:event].to_s, '${primary_key}' => param[:primary_key]}
|
172
177
|
tag.gsub(/\${[a-z_]+(\[[0-9]+\])?}/, pattern) do
|
173
|
-
$log.warn "mysql_replicator_multi: missing placeholder. tag
|
178
|
+
$log.warn "mysql_replicator_multi: missing placeholder. :tag=>#{tag} :placeholder=>#{$1}" unless pattern.include?($1)
|
174
179
|
pattern[$1]
|
175
180
|
end
|
176
181
|
end
|