murakumo 0.6.0 → 0.6.1

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.
data/README CHANGED
@@ -14,7 +14,6 @@ https://github.com/cookpad/murakumo
14
14
  * SQLite
15
15
  * Ruby1.9 (murakumo version is 0.6.0 or more)
16
16
 
17
-
18
17
  == Install
19
18
 
20
19
  shell> gem install murakumo
@@ -1,5 +1,5 @@
1
1
  module Murakumo
2
- VERSION = Version = '0.6.0'
2
+ VERSION = Version = '0.6.1'
3
3
 
4
4
  # Priority
5
5
  MASTER = 1
@@ -60,23 +60,26 @@ module Murakumo
60
60
  end
61
61
  end
62
62
 
63
+ # MySQLチェッカー
63
64
  begin
64
- require 'mysql'
65
+ require 'mysql2/em'
65
66
 
66
67
  def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
67
- port = nil
68
- sock = nil
68
+ opts = {}
69
+ opts[:username] = user
70
+ opts[:password] = passwd if passwd
71
+ opts[:host] = host if host
72
+ opts[:database] = db if db
73
+ opts[:connect_timeout] = @options['timeout']
69
74
 
70
75
  if port_sock.kind_of?(Integer)
71
- port = port_sock
76
+ opts[:port] = port_sock
72
77
  else
73
- sock = port_sock
78
+ opts[:socket] = port_sock
74
79
  end
75
80
 
76
- my = Mysql.init
77
- my.options(Mysql::OPT_CONNECT_TIMEOUT, @options['timeout'])
78
- my.connect(host, user, passwd, db, port, sock)
79
- !!(my.respond_to?(:ping) ? my.ping : my.stat)
81
+ my = Mysql2::EM::Client.new(opts)
82
+ my.ping
80
83
  rescue => e
81
84
  @logger.debug("#{@name}: #{e.message}")
82
85
  return false
@@ -90,24 +93,22 @@ module Murakumo
90
93
 
91
94
  unless method_defined?(:mysql_check)
92
95
  begin
93
- require 'mysql2'
96
+ require 'mysql'
94
97
 
95
98
  def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
96
- opts = {}
97
- opts[:username] = user
98
- opts[:password] = passwd if passwd
99
- opts[:host] = host if host
100
- opts[:database] = db if db
101
- opts[:connect_timeout] = @options['timeout']
99
+ port = nil
100
+ sock = nil
102
101
 
103
102
  if port_sock.kind_of?(Integer)
104
- opts[:port] = port_sock
103
+ port = port_sock
105
104
  else
106
- opts[:socket] = port_sock
105
+ sock = port_sock
107
106
  end
108
107
 
109
- my = Mysql2::Client.new(opts)
110
- my.ping
108
+ my = Mysql.init
109
+ my.options(Mysql::OPT_CONNECT_TIMEOUT, @options['timeout'])
110
+ my.connect(host, user, passwd, db, port, sock)
111
+ !!(my.respond_to?(:ping) ? my.ping : my.stat)
111
112
  rescue => e
112
113
  @logger.debug("#{@name}: #{e.message}")
113
114
  return false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: murakumo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: