activerecord-mysql2-retry-ext 0.1.0

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@activerecord-mysql2-retry-ext --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activerecord-mysql2-retry-ext.gemspec
4
+ gemspec
@@ -0,0 +1,5 @@
1
+ This code is for monkey-patching the Mysql2Adapter with ActiveRecord to avoid the following error when running integration tests with something like Capybara and Selenium or Capybara and Webkit: *Mysql2::Error: This connection is still waiting for a result, try again once you have the result*
2
+
3
+ The issue is alive and well: https://github.com/brianmario/mysql2/issues/99
4
+
5
+ Do not use this in production.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "activerecord-mysql2-retry-ext/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "activerecord-mysql2-retry-ext"
7
+ s.version = Activerecord::Mysql2::Retry::Ext::VERSION
8
+ s.authors = ["Zach Dennis"]
9
+ s.email = ["zach.dennis@gmail.com"]
10
+ s.homepage = "https://github.com/zdennis/activerecord-mysql2-retry-ext"
11
+ s.summary = %q{Provides auto retrying of SQL queries for the Mysql2 adapter.}
12
+ s.description = %q{
13
+ Something with the combination of Rails 3.1, Mysql2 0.3.x, Capybara,
14
+ Selenium/Webkit/etc causes Mysql to raise exceptions where the connection is
15
+ waiting on a result. This gem provides an auto-retry capability with the
16
+ Mysql2Adapter to retry any query execution up to 5 times. This is a a temporary
17
+ solution until the real issue with the above libraries/frameworks are resolved. This
18
+ should NOT be used in production.
19
+ }
20
+
21
+ s.rubyforge_project = "activerecord-mysql2-retry-ext"
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.require_paths = ["lib"]
27
+
28
+ # specify any dependencies here; for example:
29
+ # s.add_development_dependency "rspec"
30
+ s.add_runtime_dependency "activerecord", "~> 3.1.0"
31
+ s.add_runtime_dependency "mysql2", "~> 0.3"
32
+ end
@@ -0,0 +1,19 @@
1
+ require "active_record/connection_adapters/mysql2_adapter"
2
+ require "activerecord-mysql2-retry-ext/version"
3
+
4
+ class ActiveRecord::ConnectionAdapters::Mysql2Adapter
5
+ # +exec_query_with_retry+ tries the attempted query and retries it up to 5 times
6
+ # before raising an ActiveRecord::StatementInvalid exception.
7
+ def exec_query_with_retry(*args)
8
+ retry_count = 0
9
+ begin
10
+ exec_query_without_retry *args
11
+ rescue ActiveRecord::StatementInvalid => ex
12
+ retry_count +=1
13
+ retry if retry_count < 5
14
+ raise ex
15
+ end
16
+ end
17
+ alias_method :exec_query_without_retry, :exec_query
18
+ alias_method :exec_query, :exec_query_with_retry
19
+ end
@@ -0,0 +1,9 @@
1
+ module Activerecord
2
+ module Mysql2
3
+ module Retry
4
+ module Ext
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-mysql2-retry-ext
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Zach Dennis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-09-26 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activerecord
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 3.1.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "0.3"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: "\n Something with the combination of Rails 3.1, Mysql2 0.3.x, Capybara,\n Selenium/Webkit/etc causes Mysql to raise exceptions where the connection is\n waiting on a result. This gem provides an auto-retry capability with the\n Mysql2Adapter to retry any query execution up to 5 times. This is a a temporary\n solution until the real issue with the above libraries/frameworks are resolved. This\n should NOT be used in production. \n "
39
+ email:
40
+ - zach.dennis@gmail.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - .rvmrc
50
+ - Gemfile
51
+ - README.markdown
52
+ - Rakefile
53
+ - activerecord-mysql2-retry-ext.gemspec
54
+ - lib/activerecord-mysql2-retry-ext.rb
55
+ - lib/activerecord-mysql2-retry-ext/version.rb
56
+ has_rdoc: true
57
+ homepage: https://github.com/zdennis/activerecord-mysql2-retry-ext
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project: activerecord-mysql2-retry-ext
80
+ rubygems_version: 1.6.2
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Provides auto retrying of SQL queries for the Mysql2 adapter.
84
+ test_files: []
85
+