statelydb 0.7.0 → 0.8.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: 2a1e0f8a92fb069b35013afdfd66b98ba831118a6c61f6825049d25ef892c42b
4
- data.tar.gz: 5aae07d1f1e704d7715235ba315d573976245d1237a2ed256127fe0c23828650
3
+ metadata.gz: 5a195c44ae0509bce7638e0b0f702e2fa9d61a22c6edfb61c09fb4c76065cd83
4
+ data.tar.gz: 3fa3ac72792f70c203b63c52e3ca0987c39bbc0c7f7fbee8fcf47ea407028360
5
5
  SHA512:
6
- metadata.gz: d1bf5854d4726dbdc17782451af7f5e8c52ea63bd7cc9f6cd26bc7f74c6c2af8bd20e2c8a79bf49b6ab66ff9a39f6fee6cdb060b26d3777fcc8a837845b3dda9
7
- data.tar.gz: 9b60c991d8fcf38fc3f22b90669a99747ccafa07b22a7779e1175a5f0d4094ac212906f710df415001220029243ddc4fd066c36d3d37e40dcd4d9c8e6f5a5753
6
+ metadata.gz: e7f2a619018c507f1d4bffe72f1c3dd1abe761102453c2c6acd499ec4c8400a9b97d7c63befadc41dc6dd44c35d371d78ae172e3d2917e3ab87bb3c3e5461ea4
7
+ data.tar.gz: 0527abd449a1d079c8553109966b346a30bce559de872f48e1e857f4677e027e23e7f6012592d56edb3c9b5dff0785b1b010d3ad8604716ea6a3f2308ffd0da8
@@ -100,10 +100,11 @@ module StatelyDB
100
100
  # there is no non-blocking sleep in ruby.
101
101
  # skip this if we have a pending timer thread already
102
102
  @timer = Thread.new do
103
- # TODO: - add some random jitter to stop clients getting a cycle after
104
- # some event like an outage
105
- # Also, don't let this be less than 1sec
106
- delay = [resp_data["expires_in"] - 10, 1].max
103
+ # Calculate a random multiplier between 0.3 and 0.8 to to apply to the expiry
104
+ # so that we refresh in the background ahead of expiration, but avoid
105
+ # multiple processes hammering the service at the same time.
106
+ jitter = (Random.rand * 0.5) + 0.3
107
+ delay = resp_data["expires_in"] * jitter
107
108
  sleep(delay)
108
109
  refresh_token
109
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statelydb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stately Cloud, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-28 00:00:00.000000000 Z
11
+ date: 2024-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async