statelydb 0.6.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: 0eb53c16c6251cf93076f780e932541700ccb6f023b98062441d8e6b2befebe1
4
- data.tar.gz: 1cc3cde2aeceb6bb8a63e69289edea027e14870b4d53bad321ca40994c7d61e3
3
+ metadata.gz: 5a195c44ae0509bce7638e0b0f702e2fa9d61a22c6edfb61c09fb4c76065cd83
4
+ data.tar.gz: 3fa3ac72792f70c203b63c52e3ca0987c39bbc0c7f7fbee8fcf47ea407028360
5
5
  SHA512:
6
- metadata.gz: d6854cd8d7f966eb921edb9ab13202ca886e4e28a17c6d02cf0ac1bc9958491bb2d85a8e67a7a6e05b0bdc352135776ec9d371b98cce8ec570bf36ff7678c757
7
- data.tar.gz: 5665372c41462b6cea5fe2a830f7a22150010a42754a0ad06dc2848de06c397b2a901e703305a3644b70608d17e619876f2b133141aefd3cc0c53d89e4f732c5
6
+ metadata.gz: e7f2a619018c507f1d4bffe72f1c3dd1abe761102453c2c6acd499ec4c8400a9b97d7c63befadc41dc6dd44c35d371d78ae172e3d2917e3ab87bb3c3e5461ea4
7
+ data.tar.gz: 0527abd449a1d079c8553109966b346a30bce559de872f48e1e857f4677e027e23e7f6012592d56edb3c9b5dff0785b1b010d3ad8604716ea6a3f2308ffd0da8
data/README.md CHANGED
@@ -29,7 +29,7 @@ gem install statelydb
29
29
  Create an authenticated client, then import your item types from your generated schema module and use the client!
30
30
 
31
31
  ```ruby
32
- require_relative 'schema/stately.item_types'
32
+ require_relative 'schema/stately'
33
33
 
34
34
  def put_my_item
35
35
  # Create a client. This will use the environment variables
@@ -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.6.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-27 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