realogy 0.6.10 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35e5c36fc0a5bd0540a03d4a2b15a27f0308843e3ee9f8c444d7b62ab9ab449f
4
- data.tar.gz: 6d7765533f529ceff5d733cb2d524ca2dd82ff02620f8216ff6c253b09d6f2c6
3
+ metadata.gz: 9a2d6245885bf9792e71bb2089816b5959fb6b7749ec87f254601c4d3896d1d6
4
+ data.tar.gz: 3370e31d672737acbccbf1b2507ef929294f16630dc91c522c75c11249917dea
5
5
  SHA512:
6
- metadata.gz: 0ca7f3041d3b123890046ca83bd0558b8a713030253186a9fc2882a5fc4297f09d4b89b04a119062a0c9ba8d7c32fdcbe01d2942bd696b1b87bd499fc45b0e0d
7
- data.tar.gz: 9866700d33eda367d057882ab5b127eb8bc106f369315db4a7d16f75863baab767f91dcbeb27dd0db0e91a6fd30c3567da7a14845f1e00e17fc28fa0035f6d89
6
+ metadata.gz: 625d3bdc5529d6530e510efe75b0e391b5a03fa46213de2e7e08a4780a0c44fccb4903abfe76d71caa94920e676a3deb3e8fcab59704840cf297151b2f4ed5bb
7
+ data.tar.gz: 0ffd6581d0e134744e0391f4a27d64bccbc43385525bbeb82bd953cde0e65ff1c0483e84deecc33bf0fd79a09b7b924774333067b71daba3de144e3cff7ac47b
@@ -152,6 +152,10 @@ module Realogy
152
152
  request['Ocp-Apim-Subscription-Key'] = Rails.application.credentials.dig(:realogy, :subscription_key)
153
153
  request['Authorization'] = "Bearer #{auth_token}"
154
154
  response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
155
+ http.open_timeout = 10 # seconds to wait for connection
156
+ http.read_timeout = 30 # seconds to wait for response
157
+ http.write_timeout = 10
158
+ http.ssl_timeout = 10
155
159
  http.max_retries = 10
156
160
  http.request(request)
157
161
  end
@@ -1,4 +1,4 @@
1
- class Realogy::Entity < ApplicationRecord
1
+ class Realogy::Entity < Object.const_get(Realogy.base_record_class)
2
2
  self.table_name = 'realogy_entities'
3
3
 
4
4
  validates :type, presence: true
@@ -23,8 +23,26 @@ class Realogy::Entity < ApplicationRecord
23
23
  end
24
24
 
25
25
  def get_data
26
- call = ["get_", self.class.to_s.downcase.split("::").last, "_by_id"].join.to_sym
27
- Realogy::DataSync.client.__send__(call, entity_id)
26
+ retries = 0
27
+ max_retries = 3
28
+
29
+ begin
30
+ call = ["get_", self.class.to_s.downcase.split("::").last, "_by_id"].join.to_sym
31
+ Realogy::DataSync.client.__send__(call, entity_id)
32
+ rescue OpenSSL::SSL::SSLError, Net::OpenTimeout, Net::ReadTimeout, Errno::ECONNRESET => e
33
+ retries += 1
34
+ if retries <= max_retries
35
+ sleep_time = 2**retries # 2s, 4s, 8s
36
+ Rails.logger.warn "[Realogy::Entity] Retry #{retries}/#{max_retries} for #{entity_id} after
37
+ #{sleep_time}s (#{e.class})"
38
+ sleep(sleep_time)
39
+ retry
40
+ else
41
+ Rails.logger.error "[Realogy::Entity] Failed to fetch #{entity_id} after #{max_retries} retries:
42
+ #{e.message}"
43
+ raise
44
+ end
45
+ end
28
46
  end
29
47
 
30
48
  def populate
@@ -1,3 +1,3 @@
1
1
  module Realogy
2
- VERSION = "0.6.10"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/realogy.rb CHANGED
@@ -14,4 +14,14 @@ require "realogy/app/jobs/application_job.rb"
14
14
  require "realogy/app/jobs/populate_realogy_entity_job.rb"
15
15
 
16
16
  module Realogy
17
+ class << self
18
+ attr_accessor :base_record_class
19
+
20
+ def configure
21
+ yield self
22
+ end
23
+ end
24
+
25
+ # Default to ApplicationRecord for backward compatibility
26
+ self.base_record_class = 'ApplicationRecord'
17
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Edlund