statelydb 0.3.0 → 0.5.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: 8b27d32c4da703530db30a90682ed114e0c6d51d5c3dc6a686a7ab2bf766998c
4
+ data.tar.gz: f5166027a052648eba7dbda0c57b3f6a43803bfda0ab7231228439d11a30cd4c
5
5
  SHA512:
6
- metadata.gz: 1484b054ae70123705dcb70911019173d766e16dc7c748e00ac7409b26617d87e3131d11ca3d0a65b91081f7371a787818993e81ebc6af232c9dc1f685ac951a
7
- data.tar.gz: 85acbaf93fadc0c5928f47ef41d534ff93ea1b2ecdd08021fb78df456bc5451a8a14e889b8de539df72f32c81f05c1d5431762cd69309a408a80bc5e3e6b4342
6
+ metadata.gz: 68066039cfd9d52a577e2a1be1b66be66468fb40e12bb98e8a4ef4b02e4b97136c20824efa4a1bbd6cf3a099146a43aa8e44114ac5e1eb2cb5402d583773faf4
7
+ data.tar.gz: a1ee650259c49d439f32a72d7ab2161a560c0d0e27eb8c87c7a3b03c255ab369d5bd0ceedf25901234b0a93eaee996221002f1782a4e7ed923a249ba93c0f72b
data/README.md CHANGED
@@ -47,5 +47,5 @@ def put_my_item
47
47
 
48
48
  ---
49
49
 
50
- [Getting Started Guide]: https://preview-docs.stately.cloud/guides/getting-started/
51
- [Defining Schema]: https://preview-docs.stately.cloud/guides/defining-schema/
50
+ [Getting Started Guide]: https://docs.stately.cloud/guides/getting-started/
51
+ [Defining Schema]: https://docs.stately.cloud/guides/schema/
@@ -40,12 +40,12 @@ module Stately
40
40
  # always applied atomically; all will fail or all will succeed.
41
41
  rpc :Delete, ::Stately::Db::DeleteRequest, ::Stately::Db::DeleteResponse
42
42
  # BeginList retrieves Items that start with a specified key path prefix. The
43
- # key path prefix must minimally contain a Group Key (an item type and an
44
- # item ID). BeginList will return an empty result set if there are no items
45
- # matching that key prefix. This API returns a token that you can pass to
46
- # ContinueList to expand the result set, or to SyncList to get updates within
47
- # the result set. This can fail if the caller does not have permission to
48
- # read Items.
43
+ # key path prefix must minimally contain a Group Key (a single key segment
44
+ # with a namespace and an ID). BeginList will return an empty result set if
45
+ # there are no items matching that key prefix. This API returns a token that
46
+ # you can pass to ContinueList to expand the result set, or to SyncList to
47
+ # get updates within the result set. This can fail if the caller does not
48
+ # have permission to read Items.
49
49
  # buf:lint:ignore RPC_RESPONSE_STANDARD_NAME
50
50
  rpc :BeginList, ::Stately::Db::BeginListRequest, stream(::Stately::Db::ListResponse)
51
51
  # ContinueList takes the token from a BeginList call and returns more results
@@ -5,7 +5,7 @@
5
5
  require 'google/protobuf'
6
6
 
7
7
 
8
- descriptor_data = "\n\x1a\x65rrors/error_details.proto\x12\x0estately.errors\"y\n\x13StatelyErrorDetails\x12!\n\x0cstately_code\x18\x01 \x01(\tR\x0bstatelyCode\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\x12%\n\x0eupstream_cause\x18\x03 \x01(\tR\rupstreamCauseB\x80\x01\n\x12\x63om.stately.errorsB\x11\x45rrorDetailsProtoP\x01\xa2\x02\x03SEX\xaa\x02\x0eStately.Errors\xca\x02\x0eStately\\Errors\xe2\x02\x1aStately\\Errors\\GPBMetadata\xea\x02\x0fStately::Errorsb\x06proto3"
8
+ descriptor_data = "\n\x1a\x65rrors/error_details.proto\x12\x0estately.errors\"\x8d\x01\n\x13StatelyErrorDetails\x12!\n\x0cstately_code\x18\x01 \x01(\tR\x0bstatelyCode\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\x12%\n\x0eupstream_cause\x18\x03 \x01(\tR\rupstreamCause\x12\x12\n\x04\x63ode\x18\x04 \x01(\rR\x04\x63odeB\x80\x01\n\x12\x63om.stately.errorsB\x11\x45rrorDetailsProtoP\x01\xa2\x02\x03SEX\xaa\x02\x0eStately.Errors\xca\x02\x0eStately\\Errors\xe2\x02\x1aStately\\Errors\\GPBMetadata\xea\x02\x0fStately::Errorsb\x06proto3"
9
9
 
10
10
  pool = Google::Protobuf::DescriptorPool.generated_pool
11
11
  pool.add_serialized_file(descriptor_data)
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.5.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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async