mysql_stay_connected 0.0.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/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mysql-stay-connected.gemspec
4
+ gemspec
5
+
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mysql_stay_connected (0.0.1)
5
+ activerecord (>= 2.3.5)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.8)
11
+ activesupport (= 3.2.8)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.8)
14
+ activemodel (= 3.2.8)
15
+ activesupport (= 3.2.8)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.8)
19
+ i18n (~> 0.6)
20
+ multi_json (~> 1.0)
21
+ arel (3.0.2)
22
+ builder (3.0.0)
23
+ i18n (0.6.1)
24
+ multi_json (1.3.6)
25
+ tzinfo (0.3.33)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ mysql_stay_connected!
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Socialcast, Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # mysql_stay_connected
2
+
3
+ Ensure that a lost mysql connection will be reestablished (works for mysql and mysql 2 adaptor)
4
+
5
+ ## Configuration
6
+
7
+ NONE!
8
+
9
+ ## Installation
10
+
11
+ ``` ruby
12
+ # Bundler Gemfile
13
+ gem 'mysql_stay_connected'
14
+ ```
15
+
16
+ ## Contributing
17
+
18
+ * Fork the project
19
+ * Fix the issue
20
+ * Create pull request on github
@@ -0,0 +1,32 @@
1
+ # If your workers are inactive for a long period of time, they'll lose
2
+ # their MySQL connection.
3
+ #
4
+ # This hack ensures we re-connect whenever a connection is
5
+ # lost. Because, really. why not?
6
+ #
7
+ # Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
8
+ #
9
+ # From:
10
+ # http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
11
+ # https://gist.github.com/238999
12
+ #
13
+ require 'active_record/connection_adapters/abstract_mysql_adapter'
14
+ require 'mysql_stay_connected/version'
15
+
16
+ module ActiveRecord::ConnectionAdapters
17
+ class AbstractMysqlAdapter
18
+ alias_method :execute_without_retry, :execute
19
+
20
+ def execute(*args)
21
+ execute_without_retry(*args)
22
+ rescue ActiveRecord::StatementInvalid => e
23
+ if e.message =~ /server has gone away/i
24
+ warn "Server timed out, retrying"
25
+ reconnect!
26
+ retry
27
+ else
28
+ raise e
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ module MysqlStayConnected
2
+ VERSION = "0.0.1"
3
+ end
4
+
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "mysql_stay_connected/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "mysql_stay_connected"
7
+ s.version = MysqlStayConnected::VERSION
8
+ s.authors = ["Dirk Eisenberg"]
9
+ s.email = ["dirk.eisenberg@gmail.com"]
10
+ s.homepage = 'http://rubygems.org/gems/mysql-stay-connected'
11
+ s.summary = %q{ensure active record connections will be reestablished if needed}
12
+ s.description = %q{ensure active record connections will be reestablished if needed}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
20
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mysql_stay_connected
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dirk Eisenberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.5
30
+ description: ensure active record connections will be reestablished if needed
31
+ email:
32
+ - dirk.eisenberg@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - lib/mysql_stay_connected.rb
42
+ - lib/mysql_stay_connected/version.rb
43
+ - mysql_stay_connected.gemspec
44
+ homepage: http://rubygems.org/gems/mysql-stay-connected
45
+ licenses: []
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.23
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: ensure active record connections will be reestablished if needed
68
+ test_files: []