pg_reconnect 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # PgReconnect
2
2
 
3
- ActiveRecord PostgreSql auto-reconnection, works with 2.3 and 3.2 rails.
3
+ ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails.
4
+ Uses hackety wrapper on adapter execute.
4
5
 
5
6
  ## Installation
6
7
 
@@ -10,17 +10,18 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
10
10
  @retry_counter = nil
11
11
  res
12
12
  rescue ActiveRecord::StatementInvalid => ex
13
- unless active?
13
+ unless active?
14
14
  @retry_counter ||= 0
15
15
  @logger.warn "Reconnecting to database after PGError! Try ##{@retry_counter + 1}/#{MAX_QUERY_RETRIES} #{ex.message}, trace: #{ex.backtrace.inspect}"
16
- reconnect! rescue nil
17
16
 
18
17
  if @retry_counter < MAX_QUERY_RETRIES
19
18
  @retry_counter += 1
19
+ reconnect! rescue nil # to prevent error PG::Error: invalid encoding name: utf8
20
20
  retry
21
21
  end
22
22
  end
23
-
23
+
24
+ @retry_counter = 0
24
25
  raise
25
26
  end
26
27
 
@@ -32,14 +33,15 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
32
33
  unless active?
33
34
  @retry_counter ||= 0
34
35
  @logger.warn "Reconnecting to database after PGError! Try ##{@retry_counter + 1}/#{MAX_QUERY_RETRIES} #{ex.message}, trace: #{ex.backtrace.inspect}"
35
- reconnect! rescue nil
36
36
 
37
37
  if @retry_counter < MAX_QUERY_RETRIES
38
38
  @retry_counter += 1
39
+ reconnect! rescue nil # to prevent error PG::Error: invalid encoding name: utf8
39
40
  retry
40
41
  end
41
42
  end
42
-
43
+
44
+ @retry_counter = 0
43
45
  raise
44
46
  end
45
47
 
@@ -10,18 +10,18 @@ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
10
10
  res
11
11
  rescue ActiveRecord::StatementInvalid => ex
12
12
  unless active?
13
- reconnect! rescue nil
14
-
15
13
  @retry_counter ||= 0
16
14
  @logger.warn "Reconnecting to database after PGError! Try ##{@retry_counter + 1}/#{MAX_QUERY_RETRIES} #{ex.message}, trace: #{ex.backtrace.inspect}"
17
15
 
18
16
  if @retry_counter < MAX_QUERY_RETRIES
19
17
  @retry_counter += 1
18
+ reconnect! rescue nil
20
19
  retry
21
20
  end
22
21
  end
23
22
 
23
+ @retry_counter = 0
24
24
  raise
25
25
  end
26
-
26
+
27
27
  end
data/pg_reconnect.gemspec CHANGED
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "pg_reconnect"
7
- gem.version = "0.1"
7
+ gem.version = "0.1.1"
8
8
  gem.authors = ["'Konstantin Makarchev'"]
9
9
  gem.email = ["'kostya27@gmail.com'"]
10
- gem.description = %q{ActiveRecord PostgreSql auto-reconnection, works with 2.3 and 3.2 rails.}
11
- gem.summary = %q{ActiveRecord PostgreSql auto-reconnection, works with 2.3 and 3.2 rails.}
10
+ gem.description = %q{ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails.}
11
+ gem.summary = %q{ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails.}
12
12
  gem.homepage = ""
13
13
 
14
14
  gem.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_reconnect
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
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: 2012-12-12 00:00:00.000000000 Z
12
+ date: 2012-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -27,7 +27,7 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '2'
30
- description: ActiveRecord PostgreSql auto-reconnection, works with 2.3 and 3.2 rails.
30
+ description: ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails.
31
31
  email:
32
32
  - ! '''kostya27@gmail.com'''
33
33
  executables: []
@@ -67,6 +67,6 @@ rubyforge_project:
67
67
  rubygems_version: 1.8.24
68
68
  signing_key:
69
69
  specification_version: 3
70
- summary: ActiveRecord PostgreSql auto-reconnection, works with 2.3 and 3.2 rails.
70
+ summary: ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails.
71
71
  test_files: []
72
72
  has_rdoc: