statelydb 0.3.0 → 0.4.0

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: 8481aaa31dca18c89b20c17cea4e413165e0aa6677c5ba3eb522780f9f327559
4
- data.tar.gz: cdbfd5503bc8d8882a47b3b9fbc59c591477957572d66539c8841c55d8ad2ec4
3
+ metadata.gz: 9da53da8635a6ab8f8e30bf199d0b4fe353319888398d8ec524e3b3d7384eae5
4
+ data.tar.gz: c09b521842ffaa90a6f441328ac470af5ae8f11579058fa88d09f32fd32186fc
5
5
  SHA512:
6
- metadata.gz: 1484b054ae70123705dcb70911019173d766e16dc7c748e00ac7409b26617d87e3131d11ca3d0a65b91081f7371a787818993e81ebc6af232c9dc1f685ac951a
7
- data.tar.gz: 85acbaf93fadc0c5928f47ef41d534ff93ea1b2ecdd08021fb78df456bc5451a8a14e889b8de539df72f32c81f05c1d5431762cd69309a408a80bc5e3e6b4342
6
+ metadata.gz: fe2629a952686bc0ef0b7e46f8f826430411f8ea6569c454afd702805e53424c15b456ccb5783cdb1691a196b88f488ccde4489f04fdaaa26f1dee24f4eb1bb0
7
+ data.tar.gz: c43a2b8013e2756b3605511dca167b0197b8cea5bbf83c0ef63b2ca6fbaa99ed07c1c54a5f4b48e20fc3c126d91d57c041508bd51c67ccc717299c3d8f59556f
data/lib/statelydb.rb CHANGED
@@ -92,6 +92,7 @@ module StatelyDB
92
92
  key_paths = Array(key_paths).flatten
93
93
  req = Stately::Db::GetRequest.new(
94
94
  store_id: @store_id,
95
+ schema_version_id: @schema::SCHEMA_VERSION_ID,
95
96
  gets:
96
97
  key_paths.map { |key_path| Stately::Db::GetItem.new(key_path: String(key_path)) },
97
98
  allow_stale: @allow_stale
@@ -125,7 +126,8 @@ module StatelyDB
125
126
  limit:,
126
127
  sort_property:,
127
128
  sort_direction:,
128
- allow_stale: @allow_stale
129
+ allow_stale: @allow_stale,
130
+ schema_version_id: @schema::SCHEMA_VERSION_ID
129
131
  )
130
132
  resp = @stub.begin_list(req)
131
133
  process_list_response(resp)
@@ -188,6 +190,7 @@ module StatelyDB
188
190
  items = Array(items).flatten
189
191
  req = Stately::Db::PutRequest.new(
190
192
  store_id: @store_id,
193
+ schema_version_id: @schema::SCHEMA_VERSION_ID,
191
194
  puts: items.map do |item|
192
195
  Stately::Db::PutItem.new(
193
196
  item: item.send("marshal_stately")
@@ -214,6 +217,7 @@ module StatelyDB
214
217
  key_paths = Array(key_paths).flatten
215
218
  req = Stately::Db::DeleteRequest.new(
216
219
  store_id: @store_id,
220
+ schema_version_id: @schema::SCHEMA_VERSION_ID,
217
221
  deletes: key_paths.map { |key_path| Stately::Db::DeleteItem.new(key_path: String(key_path)) }
218
222
  )
219
223
  @stub.delete(req)
@@ -308,6 +312,7 @@ module StatelyDB
308
312
  def process_sync_response(resp)
309
313
  changed_items = []
310
314
  deleted_item_paths = []
315
+ updated_outside_list_window_paths = []
311
316
  token = nil
312
317
  is_reset = false
313
318
  resp.each do |r|
@@ -319,6 +324,9 @@ module StatelyDB
319
324
  r.result.deleted_items.each do |item|
320
325
  deleted_item_paths << item.key_path
321
326
  end
327
+ r.result.updated_item_keys_outside_list_window.each do |item|
328
+ updated_outside_list_window_paths << item.key_path
329
+ end
322
330
  when :reset
323
331
  is_reset = true
324
332
  when :finished
@@ -328,7 +336,7 @@ module StatelyDB
328
336
  can_sync: raw_token.can_sync)
329
337
  end
330
338
  end
331
- SyncResult.new(changed_items:, deleted_item_paths:, is_reset:, token:)
339
+ SyncResult.new(changed_items:, deleted_item_paths:, updated_outside_list_window_paths:, is_reset:, token:)
332
340
  end
333
341
  end
334
342
 
@@ -336,18 +344,24 @@ module StatelyDB
336
344
  #
337
345
  # @attr_reader changed_items [Array<StatelyDB::Item>] the items that were changed
338
346
  # @attr_reader deleted_item_paths [Array<String>] the key paths that were deleted
347
+ # @attr_reader updated_outside_list_window_paths [Array<String>] the key paths of
348
+ # items that were updated but Stately cannot tell if they were in the sync window.
349
+ # Treat these as deleted in most cases.
339
350
  # @attr_reader is_reset [Boolean] whether the sync operation reset the token
340
351
  # @attr_reader token [StatelyDB::Token] the token to continue from
341
352
  class SyncResult
342
- attr_reader :changed_items, :deleted_item_paths, :is_reset, :token
353
+ attr_reader :changed_items, :deleted_item_paths, :updated_outside_list_window_paths, :is_reset, :token
343
354
 
344
355
  # @param changed_items [Array<StatelyDB::Item>] the items that were changed
345
356
  # @param deleted_item_paths [Array<String>] the key paths that were deleted
357
+ # @param updated_outside_list_window_paths [Array<String>] key paths for items that were updated
358
+ # but do not currently use the sort property that the list window is based on
346
359
  # @param is_reset [Boolean] whether the sync operation reset the token
347
360
  # @param token [StatelyDB::Token] the token to continue from
348
- def initialize(changed_items:, deleted_item_paths:, is_reset:, token:)
361
+ def initialize(changed_items:, deleted_item_paths:, updated_outside_list_window_paths:, is_reset:, token:)
349
362
  @changed_items = changed_items
350
363
  @deleted_item_paths = deleted_item_paths
364
+ @updated_outside_list_window_paths = updated_outside_list_window_paths
351
365
  @is_reset = is_reset
352
366
  @token = token
353
367
  end
@@ -124,7 +124,10 @@ module StatelyDB
124
124
  # @!visibility private
125
125
  def begin
126
126
  @is_transaction_open = true
127
- req = Stately::Db::TransactionRequest.new(begin: Stately::Db::TransactionBegin.new(store_id: @store_id.to_i))
127
+ req = Stately::Db::TransactionRequest.new(
128
+ begin: Stately::Db::TransactionBegin.new(store_id: @store_id.to_i,
129
+ schema_version_id: @schema::SCHEMA_VERSION_ID)
130
+ )
128
131
  request_only(req)
129
132
  @incoming_responses = @stub.transaction(@outgoing_requests)
130
133
  nil
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.3.0
4
+ version: 0.4.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-15 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async