active_record_api-request 0.3.15 → 0.3.16

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: 07723fe8a0e7ef8a09d646992c72e93f334473b2f90a86e74af704beb1e8b054
4
- data.tar.gz: a6a7af0c05535d34ee363e455b3f3162d27a9f8c9990e8e4349cded201e7335b
3
+ metadata.gz: 3e1be4753a2cf5b8394c7313ee0b005a6228646fa71b92fa6574cc73e1825d5f
4
+ data.tar.gz: 43ae9b78126a3880af7a5796dcef31c86b11aa283f6291e078a57915414bf5be
5
5
  SHA512:
6
- metadata.gz: 35c489d8cb6613b5b933b7a1cfdd258085a490d8cc76ad9efb908db450d27409566af8c05d5b83eabb0ddc07a57fd1c99ec9102c7b1a880979b50f6979b198b6
7
- data.tar.gz: 4b4ad95507d5af98fc3a0061e3f97807d84f873c3de8e4d4bd6f35708fedbb5295e6a5f4295eda01e220d50c6df6957fcba86e628b747c23b41be81980b7c69d
6
+ metadata.gz: '008d6a81a7346699fc0cb9f0089ba6ecc7d7cd0b33fe48238e4cedad91ff9914d0cc111df64b20b5e60ad0d2625860ae6a3e1aa36e35f44b7f73c19de3513945'
7
+ data.tar.gz: 96ad30c6ff561125efbee2238c8f4bafbbf282528326ec1d593b74d15489787db01c7530b68971a838342b7262aff14b4437a8e330bfab8de85f6c09199c2bc7
@@ -3,7 +3,7 @@ module ActiveRecordApi
3
3
  module Request
4
4
  class TokenCache
5
5
  include ActiveAttr::Model
6
- attr_accessor :debug
6
+ attr_accessor :debug
7
7
 
8
8
  def flush
9
9
  return unless defined? AUTH_REDIS_POOL
@@ -33,14 +33,14 @@ module ActiveRecordApi
33
33
  @token = nil
34
34
  @retry = 0
35
35
  while @token.nil? && @retry < 5
36
- @retry += 1
37
36
  @token = @redis_client.get('auth_token')
38
37
  debug_log "retry ##{@retry}"
39
38
  debug_log "found token: #{@token}"
39
+ @retry += 1
40
40
  if @token.nil? || session_missing_for?(@token)
41
41
  if acquire_lock
42
42
  begin
43
- debug_log "acquired lock and fetching token for cache"
43
+ debug_log 'acquired lock and fetching token for cache'
44
44
  @token = token_proc.call
45
45
  raise "no token returned! #{@token}" if @token.nil?
46
46
  @redis_client.set 'auth_token', @token
@@ -70,7 +70,7 @@ module ActiveRecordApi
70
70
  return nil
71
71
  end
72
72
 
73
- @redis_session ||= Redis.new({url: "redis://#{ENV['REDIS_SESSION_HOST']}", db: ENV['REDIS_SESSION']})
73
+ @redis_session ||= Redis.new({ url: "redis://#{ENV['REDIS_SESSION_HOST']}", db: ENV['REDIS_SESSION'] })
74
74
  end
75
75
 
76
76
  def session_missing_for?(token)
@@ -86,7 +86,7 @@ module ActiveRecordApi
86
86
  end
87
87
 
88
88
  def acquire_lock
89
- @redis_client.set 'auth_token_lock', unique_key, nx: true, ex: 60
89
+ @redis_client.set 'auth_token_lock', unique_key, nx: true, ex: 8
90
90
  current_lock_value = @redis_client.get 'auth_token_lock'
91
91
  debug_log "#{current_lock_value} == #{unique_key}"
92
92
  current_lock_value == unique_key
@@ -102,4 +102,5 @@ module ActiveRecordApi
102
102
  end
103
103
  end
104
104
  end
105
+
105
106
  #:nocov:#
@@ -1,5 +1,5 @@
1
1
  module ActiveRecordApi
2
2
  module Request
3
- VERSION = '0.3.15'.freeze
3
+ VERSION = '0.3.16'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_api-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Full Measure Education
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr