bridge_cache 0.3.17 → 0.3.19

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
  SHA256:
3
- metadata.gz: 0dd1fe1e90aad155eaa304b9fad18ee2846e410b4255f7d69be0a580d9a2fde0
4
- data.tar.gz: '02239747587e0856884680bed5234f88e35ae8cdb7118ad4a2458f19196c9b9f'
3
+ metadata.gz: 4e0ef250eb9395352435e1651e2e2f64c9233ec7446dde9d93525c0cf26b7542
4
+ data.tar.gz: a7b54fef68c133c6a6012ccbf7ab7df18ecc73dadca293695456250dcd10c644
5
5
  SHA512:
6
- metadata.gz: 83ce65775f28119f37cd88f66aee9cd4effcad429538dc15e2aef88f79463ada2278da42e63350af6620721d2cddda340889f21a85c2d3f9bba2ca21e6308448
7
- data.tar.gz: e8d759746b5bcd2f5606b61141f1da9ab8e0646d5e796420e96f9c397d8db064138750308ca9651177cd40c6007f795269fb1e863ba583c3853d708569f20ad2
6
+ metadata.gz: '05824d1406cec5c682f470d4cb4d3710ecff169a95add65899e345379b5f72317ed645548e04e4f276da1b72124c07ed40d3eb8fc6eb76c5490ecd5a31942008'
7
+ data.tar.gz: 166dc215b08233ff207146b5a6d9b831de4e5f6747c4a94a84278f4c561ea740c4ebb11af4b5e8b9a839f21cee36b52e9184f892af33373a77cdf863f8c33775
@@ -5,17 +5,24 @@ module BridgeCache::Jobs
5
5
 
6
6
  ATTEMPTS_THRESHOLD = 30
7
7
 
8
- def perform(account_settings, attempts, chain = [])
9
- account_settings = account_settings.with_indifferent_access
10
- remote_data = BridgeBlueprint::RemoteData.new(account_settings[:url], account_settings[:api_key], account_settings[:api_secret])
8
+ def remote_data
9
+ @remote_data ||= BridgeBlueprint::RemoteData.new(@account_settings[:url], @account_settings[:api_key], @account_settings[:api_secret])
10
+ end
11
+
12
+ def perform(account_settings, attempts, chain = [], retries = 0)
13
+ @account_settings = account_settings.with_indifferent_access
11
14
  if attempts > ATTEMPTS_THRESHOLD
12
15
  Rails.logger.fatal("Bridge data dump failed to download after #{(ATTEMPTS_THRESHOLD * 30) / 60} minutes")
13
16
  elsif remote_data.status == BridgeBlueprint::Constants::STATUS_COMPLETE
14
- BridgeCache::Jobs::ImportData.set(queue: queue_name).perform_later(account_settings, chain)
17
+ BridgeCache::Jobs::ImportData.set(queue: queue_name).perform_later(@account_settings, chain)
15
18
  elsif remote_data.status == BridgeBlueprint::Constants::STATUS_PENDING
16
- BridgeCache::Jobs::ImportCheck.set(queue: queue_name, wait: 30.seconds).perform_later(account_settings, attempts + 1, chain)
19
+ BridgeCache::Jobs::ImportCheck.set(queue: queue_name, wait: 30.seconds).perform_later(@account_settings, attempts + 1, chain)
17
20
  elsif remote_data.status == BridgeBlueprint::Constants::STATUS_FAILED || remote_data.status == BridgeBlueprint::Constants::STATUS_NOT_FOUND
18
- raise 'Bridge data dump download failed'
21
+ if retries < 1
22
+ raise 'Bridge data dump download failed'
23
+ else
24
+ BridgeCache::Jobs::ImportStart.set(queue: queue_name).perform_later(@account_settings, chain, retries - 1)
25
+ end
19
26
  end
20
27
  end
21
28
  end
@@ -2,7 +2,7 @@ module BridgeCache::Jobs
2
2
  class ImportStart < ActiveJob::Base
3
3
  queue_as :default
4
4
 
5
- def perform(account_settings, chain = [])
5
+ def perform(account_settings, chain = [], retries = 0)
6
6
  data = BridgeBlueprint::RemoteData.new(account_settings[:url], account_settings[:api_key], account_settings[:api_secret])
7
7
  data.start_data_report
8
8
  BridgeCache::Jobs::ImportCheck
@@ -10,7 +10,8 @@ module BridgeCache::Jobs
10
10
  .perform_later(
11
11
  account_settings,
12
12
  0,
13
- chain
13
+ chain,
14
+ retries
14
15
  )
15
16
  end
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module BridgeCache
2
- VERSION = '0.3.17'.freeze
2
+ VERSION = '0.3.19'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - jshaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2020-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-import