statelydb 0.7.0 → 0.9.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: 0ab280ee4fd3fa97d0664bdb6b5337fa2492fe952b3490f8cc6af1d93bd30174
4
+ data.tar.gz: db12681d9ad3e39dd642cddda23dde195f1e584da9119659ba995daec303909b
5
5
  SHA512:
6
- metadata.gz: d1bf5854d4726dbdc17782451af7f5e8c52ea63bd7cc9f6cd26bc7f74c6c2af8bd20e2c8a79bf49b6ab66ff9a39f6fee6cdb060b26d3777fcc8a837845b3dda9
7
- data.tar.gz: 9b60c991d8fcf38fc3f22b90669a99747ccafa07b22a7779e1175a5f0d4094ac212906f710df415001220029243ddc4fd066c36d3d37e40dcd4d9c8e6f5a5753
6
+ metadata.gz: 5437b8f31d4300a9409b4bea9e4db3c2f046a3f8f1b3b9e55646c10fd1e24e37e1147ee2afe6a6562e8f4d1f6abc130b9525896c1c1b9816108adc27b5c62342
7
+ data.tar.gz: dff2b5feb310a189392d270835e63110ab273ca54e71d12ae2fcd58222d412e364f80c8f7e849e4249241c4242ff8ada2595fa5ad1790580214a4efccbfba3f4
@@ -5,7 +5,7 @@
5
5
  require 'google/protobuf'
6
6
 
7
7
 
8
- descriptor_data = "\n\x16\x64\x62/continue_list.proto\x12\nstately.db\"u\n\x13\x43ontinueListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12?\n\tdirection\x18\x02 \x01(\x0e\x32!.stately.db.ContinueListDirectionR\tdirection*N\n\x15\x43ontinueListDirection\x12\x19\n\x15\x43ONTINUE_LIST_FORWARD\x10\x00\x12\x1a\n\x16\x43ONTINUE_LIST_BACKWARD\x10\x01\x42l\n\x0e\x63om.stately.dbB\x11\x43ontinueListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
8
+ descriptor_data = "\n\x16\x64\x62/continue_list.proto\x12\nstately.db\"\xa1\x01\n\x13\x43ontinueListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12?\n\tdirection\x18\x02 \x01(\x0e\x32!.stately.db.ContinueListDirectionR\tdirection\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId*N\n\x15\x43ontinueListDirection\x12\x19\n\x15\x43ONTINUE_LIST_FORWARD\x10\x00\x12\x1a\n\x16\x43ONTINUE_LIST_BACKWARD\x10\x01\x42l\n\x0e\x63om.stately.dbB\x11\x43ontinueListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
9
9
 
10
10
  pool = Google::Protobuf::DescriptorPool.generated_pool
11
11
  pool.add_serialized_file(descriptor_data)
@@ -8,7 +8,7 @@ require 'db/item_pb'
8
8
  require 'db/list_pb'
9
9
 
10
10
 
11
- descriptor_data = "\n\x12\x64\x62/sync_list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\rdb/list.proto\"0\n\x0fSyncListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\"\xc8\x01\n\x10SyncListResponse\x12\x31\n\x05reset\x18\x01 \x01(\x0b\x32\x19.stately.db.SyncListResetH\x00R\x05reset\x12=\n\x06result\x18\x02 \x01(\x0b\x32#.stately.db.SyncListPartialResponseH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x03 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\"\x0f\n\rSyncListReset\"\xdf\x01\n\x17SyncListPartialResponse\x12\x35\n\rchanged_items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x0c\x63hangedItems\x12<\n\rdeleted_items\x18\x02 \x03(\x0b\x32\x17.stately.db.DeletedItemR\x0c\x64\x65letedItems\x12O\n%updated_item_keys_outside_list_window\x18\x03 \x03(\tR updatedItemKeysOutsideListWindow\"(\n\x0b\x44\x65letedItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathBh\n\x0e\x63om.stately.dbB\rSyncListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
11
+ descriptor_data = "\n\x12\x64\x62/sync_list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\rdb/list.proto\"\\\n\x0fSyncListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\"\xc8\x01\n\x10SyncListResponse\x12\x31\n\x05reset\x18\x01 \x01(\x0b\x32\x19.stately.db.SyncListResetH\x00R\x05reset\x12=\n\x06result\x18\x02 \x01(\x0b\x32#.stately.db.SyncListPartialResponseH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x03 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\"\x0f\n\rSyncListReset\"\xdf\x01\n\x17SyncListPartialResponse\x12\x35\n\rchanged_items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x0c\x63hangedItems\x12<\n\rdeleted_items\x18\x02 \x03(\x0b\x32\x17.stately.db.DeletedItemR\x0c\x64\x65letedItems\x12O\n%updated_item_keys_outside_list_window\x18\x03 \x03(\tR updatedItemKeysOutsideListWindow\"(\n\x0b\x44\x65letedItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathBh\n\x0e\x63om.stately.dbB\rSyncListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
12
12
 
13
13
  pool = Google::Protobuf::DescriptorPool.generated_pool
14
14
  pool.add_serialized_file(descriptor_data)
@@ -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
data/lib/stately_codes.rb CHANGED
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatelyCode
4
+ # CachedSchemaTooOld indicates that schema was recently updated and internal
5
+ # caches have not yet caught up. If this problem persists, please contact support.
6
+ #
7
+ # - Retryable
8
+ # This error is immediately retryable.
9
+ CACHED_SCHEMA_TOO_OLD = "CachedSchemaTooOld"
10
+
4
11
  # ConcurrentModification indicates the current transaction was aborted
5
12
  # because of a non-serializable interaction with another transaction was
6
13
  # detected, a stale read was detected, or because attempts to resolve an
data/lib/statelydb.rb CHANGED
@@ -142,7 +142,8 @@ module StatelyDB
142
142
  # client.data.continue_list(token)
143
143
  def continue_list(token)
144
144
  req = Stately::Db::ContinueListRequest.new(
145
- token_data: token.token_data
145
+ token_data: token.token_data,
146
+ schema_version_id: @schema::SCHEMA_VERSION_ID
146
147
  )
147
148
  resp = @stub.continue_list(req)
148
149
  process_list_response(resp)
@@ -158,7 +159,8 @@ module StatelyDB
158
159
  # client.data.sync_list(token)
159
160
  def sync_list(token)
160
161
  req = Stately::Db::SyncListRequest.new(
161
- token_data: token.token_data
162
+ token_data: token.token_data,
163
+ schema_version_id: @schema::SCHEMA_VERSION_ID
162
164
  )
163
165
  resp = @stub.sync_list(req)
164
166
  process_sync_response(resp)
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.9.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-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async