fluent-plugin-mysql-query 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-mysql-query"
6
- s.version = "0.2.1"
6
+ s.version = "0.2.2"
7
7
  s.authors = ["Kentaro Yoshida"]
8
8
  s.email = ["y.ken.studio@gmail.com"]
9
9
  s.homepage = "https://github.com/y-ken/fluent-plugin-mysql-query"
@@ -24,7 +24,7 @@ module Fluent
24
24
 
25
25
  def configure(conf)
26
26
  super
27
- @hostname = get_mysql_hostname
27
+ @hostname = nil
28
28
  @interval = Config.time_value(@interval)
29
29
  @nest_result = Config.bool_value(@nest_result) || false
30
30
  @row_count = Config.bool_value(@row_count) || false
@@ -42,6 +42,7 @@ module Fluent
42
42
 
43
43
  def run
44
44
  loop do
45
+ @hostname = get_mysql_hostname if @hostname.nil?
45
46
  tag = "#{@tag}".gsub('__HOSTNAME__', @hostname).gsub('${hostname}', @hostname)
46
47
  record = Hash.new
47
48
  record.store('hostname', @hostname) if @record_hostname
@@ -60,15 +61,21 @@ module Fluent
60
61
  end
61
62
 
62
63
  def get_connection
63
- return Mysql2::Client.new({
64
- :host => @host,
65
- :port => @port,
66
- :username => @username,
67
- :password => @password,
68
- :database => @database,
69
- :encoding => @encoding,
70
- :reconnect => true
71
- })
64
+ begin
65
+ return Mysql2::Client.new({
66
+ :host => @host,
67
+ :port => @port,
68
+ :username => @username,
69
+ :password => @password,
70
+ :database => @database,
71
+ :encoding => @encoding,
72
+ :reconnect => true
73
+ })
74
+ rescue Exception => e
75
+ $log.warn "mysql_query: #{e}"
76
+ sleep @interval
77
+ retry
78
+ end
72
79
  end
73
80
 
74
81
  def query(query)
@@ -76,7 +83,9 @@ module Fluent
76
83
  begin
77
84
  return @mysql.query(query, :cast => false, :cache_rows => false)
78
85
  rescue Exception => e
79
- $log.info "#{e.inspect}"
86
+ $log.warn "mysql_query: #{e}"
87
+ sleep @interval
88
+ retry
80
89
  end
81
90
  end
82
91
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mysql-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-29 00:00:00.000000000 Z
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
- requirement: &10854720 !ruby/object:Gem::Requirement
16
+ requirement: &22860620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *10854720
24
+ version_requirements: *22860620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fluentd
27
- requirement: &10846780 !ruby/object:Gem::Requirement
27
+ requirement: &22860160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *10846780
35
+ version_requirements: *22860160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mysql2
38
- requirement: &10846340 !ruby/object:Gem::Requirement
38
+ requirement: &22859740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *10846340
46
+ version_requirements: *22859740
47
47
  description:
48
48
  email:
49
49
  - y.ken.studio@gmail.com