mysql-pause 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.
- data/README +46 -0
- data/bin/mysql-pause +1 -0
- data/lib/mysql-pause/{abstract_mysql_adapter.rb → adapter-ext.rb} +0 -0
- data/lib/mysql-pause/constants.rb +1 -1
- data/lib/mysql-pause/server.rb +1 -0
- metadata +3 -3
data/README
CHANGED
@@ -52,3 +52,49 @@ gem install mysql-pause
|
|
52
52
|
| 1 |
|
53
53
|
+---+
|
54
54
|
1 row in set (18.01 sec)
|
55
|
+
|
56
|
+
== Extend MySQL adapter
|
57
|
+
=== Example code
|
58
|
+
|
59
|
+
require 'active_record'
|
60
|
+
require 'mysql-pause/adapter-ext'
|
61
|
+
|
62
|
+
ActiveRecord::Base.establish_connection(
|
63
|
+
:adapter => 'mysql2',
|
64
|
+
:host => '127.0.0.1',
|
65
|
+
:port => 13306,
|
66
|
+
:username => 'scott',
|
67
|
+
:password => 'tiger',
|
68
|
+
:database => 'employees',
|
69
|
+
:reconnect => true,
|
70
|
+
)
|
71
|
+
|
72
|
+
class Employee < ActiveRecord::Base; end
|
73
|
+
|
74
|
+
loop do
|
75
|
+
employee = Employee.new
|
76
|
+
employee.first_name = 'Taro'
|
77
|
+
employee.last_name = 'Yamada'
|
78
|
+
employee.save!
|
79
|
+
sleep 3
|
80
|
+
end
|
81
|
+
|
82
|
+
=== Behavior
|
83
|
+
|
84
|
+
log> DEBUG -- : (0.6ms) BEGIN
|
85
|
+
log> DEBUG -- : SQL (0.7ms) INSERT INTO `employees` (`first_name`, `last_name`) VALUES ('Taro', 'Yamada')
|
86
|
+
log> DEBUG -- : (0.8ms) COMMIT
|
87
|
+
log> DEBUG -- : (0.6ms) BEGIN
|
88
|
+
|
89
|
+
shell> mpctl pause
|
90
|
+
shell> service mysql restart
|
91
|
+
shell> mpctl resume
|
92
|
+
|
93
|
+
log> DEBUG -- : (0.6ms) BEGIN
|
94
|
+
(...handle error and reconnect...)
|
95
|
+
log> DEBUG -- : Mysql2::Error: %MYSQL_PAUSE%;;1000;;Aborted backend connection: BEGIN
|
96
|
+
log> WARN -- : ActiveRecord::StatementInvalid: Mysql2::Error: %MYSQL_PAUSE%;;1000;;Aborted backend connection: BEGIN
|
97
|
+
log> DEBUG -- : (0.3ms) BEGIN
|
98
|
+
log> DEBUG -- : SQL (2.1ms) INSERT INTO `employees` (`first_name`, `last_name`) VALUES ('Taro', 'Yamada')
|
99
|
+
log> DEBUG -- : (0.8ms) COMMIT
|
100
|
+
|
data/bin/mysql-pause
CHANGED
@@ -25,6 +25,7 @@ ARGV.options do |parser|
|
|
25
25
|
parser.on('-A', '--backend-addr=ADDR') {|v| options[:backend_addr] = v }
|
26
26
|
parser.on('-P', '--backend-port=PORT') {|v| options[:backend_port] = v.to_i }
|
27
27
|
parser.on('-i', '--inerval=N' ) {|v| options[:interval] = v.to_i }
|
28
|
+
parser.on('-n', '--threads=SIZE' ) {|v| options[:threads] = v.to_i }
|
28
29
|
parser.on('' , '--working-dir=DIR' ) {|v| options[:working_dir] = v }
|
29
30
|
parser.on('' , '--socket=SOCK_FILE' ) {|v| options[:socket] = v }
|
30
31
|
|
File without changes
|
@@ -1,2 +1,2 @@
|
|
1
1
|
APP_NAME = 'mysql-pause'
|
2
|
-
Version = '0.1.
|
2
|
+
Version = '0.1.4'
|
data/lib/mysql-pause/server.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql-pause
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- README
|
55
55
|
- bin/mpctl
|
56
56
|
- bin/mysql-pause
|
57
|
-
- lib/mysql-pause/
|
57
|
+
- lib/mysql-pause/adapter-ext.rb
|
58
58
|
- lib/mysql-pause/backend.rb
|
59
59
|
- lib/mysql-pause/constants.rb
|
60
60
|
- lib/mysql-pause/error.rb
|