dns_one 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4161ba51e675e07bce2eea75299d8de16b14863d
4
- data.tar.gz: 7270236adcd81e1ba3e37113f47b9b8214cf1e31
3
+ metadata.gz: fe691ff0349ad58c63129e862519a0d84d8f4852
4
+ data.tar.gz: 0d1f0f95be34b2df29972ecff4b6d7346b9f6436
5
5
  SHA512:
6
- metadata.gz: c17aa863f4893e78cef31be3de4dd70197a0db81f0a099a510d199bc25f61e3d0f563f4fa434124ec9d0a232573bfd4e0b2c8a170ebee0b6f6ae974797a4676c
7
- data.tar.gz: 17dd34c8031d42a28b782726f126f14b31ec5166e2d2c8578366276d3a4111724685c9753dfcc2ab5e591f9fb90bc92f286bc1516b673f15ddcab401319e4761
6
+ metadata.gz: 10a2eb9252bb99d2f76faee91885ad001dc182be34bbfd9caa72c1b23df52c821e8f686bd4bc7fd852b1d7c12f18c42c9c18e08fa9afea0e2775693e0488b72b
7
+ data.tar.gz: 936a963fd822a20bb4994fab7770bb7a396fe30e066e494de356ae6719b85a4807ecb67cee7fbabc3488a2d8efdfd1ed6d0082036865e7275eda421a5c1a6212
@@ -5,17 +5,28 @@ module Backend; class DB
5
5
  setup_db
6
6
  end
7
7
 
8
- def find dom_name
9
- sql = build_query dom_name
10
- # http://jakeyesbeck.com/2016/02/14/ruby-threads-and-active-record-connections/
8
+ def find dom_name, tries = 1
9
+ return if tries > 3
10
+
11
11
  res = nil
12
+
12
13
  begin
14
+ # http://jakeyesbeck.com/2016/02/14/ruby-threads-and-active-record-connections/
13
15
  ActiveRecord::Base.connection_pool.with_connection do
16
+ sql = build_query dom_name
14
17
  res = ActiveRecord::Base.connection.execute sql
15
18
  end
19
+
20
+ rescue ActiveRecord::StatementInvalid => e
21
+ Log.e "Query error. Trying to reconnect. Details:\n#{e.desc}"
22
+ # http://geoff.evason.name/2015/01/18/postgres-ssl-connection-has-been-closed-unexpectedly
23
+ ActiveRecord::Base.connection.reconnect!
24
+ find dom_name, (tries+1)
25
+
16
26
  rescue => e
17
27
  Log.exc e
18
28
  end
29
+
19
30
  first_record = res&.first
20
31
  record_values = first_record&.values
21
32
  record_values&.first
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  class Exception
14
14
  def desc
15
- "#{ message } #{ backtrace&.join "\n" }"
15
+ "#{e.class}: #{ message }\n#{ backtrace&.join "\n" }"
16
16
  end
17
17
  def puts_stderr
18
18
  STDERR.puts e.desc
data/lib/dns_one/log.rb CHANGED
@@ -40,7 +40,7 @@ class Log < Logger
40
40
  end
41
41
 
42
42
  def exc e
43
- e "#{e.class}: #{e.desc}"
43
+ e e.desc
44
44
  end
45
45
 
46
46
  def logger
@@ -1,3 +1,3 @@
1
1
  module DnsOne
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lobato