statelydb 0.18.2 → 0.19.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 +4 -4
- data/lib/common/error_interceptor.rb +18 -25
- data/lib/statelydb.rb +62 -2
- data/sig/statelydb.rbi +47 -43
- data/sig/statelydb.rbs +43 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48b92c6e1895bb7e7a5a27634f5012e9183b514a1210b25a54528000d8980e5d
|
4
|
+
data.tar.gz: ea786444657ea16320c913c115bac7f2cc17f3a9223d4ff53466504cac3930b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa6566c111cc334eb9015880f2d5feec32e10e571522a9609e1413ee5b7a455a7858ad599c5fcc8bc0e0ecb6a42175faf1a0aca7ecb6f402426915c7f9bba04
|
7
|
+
data.tar.gz: e4e5b788790d397ff220f28a78221c81a533bf0a8f8c58328dbe85d9085d3074fcce5b5f68fcf06b946c1858225b0ce8eabb7c84fe0641599244961dcc079f0b
|
@@ -7,33 +7,26 @@ module StatelyDB
|
|
7
7
|
module Common
|
8
8
|
# GRPC interceptor to convert errors to StatelyDB::Error
|
9
9
|
class ErrorInterceptor < GRPC::ClientInterceptor
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
# client streaming interceptor
|
18
|
-
def client_streamer(requests:, call:, method:, metadata:) # rubocop:disable Lint/UnusedMethodArgument
|
19
|
-
yield
|
20
|
-
rescue Exception => e
|
21
|
-
raise StatelyDB::Error.from(e)
|
10
|
+
# Client and Server stream handling logic
|
11
|
+
%i[request_response client_streamer server_streamer bidi_streamer].each do |method_name|
|
12
|
+
define_method(method_name) do |*args, &block|
|
13
|
+
safe_yield(*args, &block)
|
14
|
+
end
|
22
15
|
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
20
|
+
def safe_yield(*, &block)
|
21
|
+
block.call(*)
|
22
|
+
rescue Exception => e
|
23
|
+
raise StatelyDB::Error.from(e)
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
rescue Exception => e
|
35
|
-
raise StatelyDB::Error.from(e)
|
36
|
-
end
|
37
|
-
end
|
26
|
+
def safe_yield_stream(stream, &block)
|
27
|
+
stream.each do |msg|
|
28
|
+
safe_yield(msg, &block)
|
38
29
|
end
|
30
|
+
rescue Exception => e
|
31
|
+
raise StatelyDB::Error.from(e)
|
39
32
|
end
|
data/lib/statelydb.rb
CHANGED
@@ -165,6 +165,66 @@ module StatelyDB
|
|
165
165
|
process_list_response(resp)
|
166
166
|
end
|
167
167
|
|
168
|
+
# Initiates a scan request which will scan over the entire store and apply
|
169
|
+
# the provided filters. This API returns a token that you can pass to
|
170
|
+
# continue_scan to paginate through the result set. This can fail if the
|
171
|
+
# caller does not have permission to read Items.
|
172
|
+
#
|
173
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER
|
174
|
+
# OF ITEMS.
|
175
|
+
#
|
176
|
+
# @param limit [Integer] the maximum number of items to return
|
177
|
+
# @param item_types [Array<Class, String>] the item types to filter by. The returned
|
178
|
+
# items will be instances of one of these types.
|
179
|
+
# @param total_segments [Integer] the total number of segments to divide the
|
180
|
+
# scan into. Use this when you want to parallelize your operation.
|
181
|
+
# @param segment_index [Integer] the index of the segment to scan.
|
182
|
+
# Use this when you want to parallelize your operation.
|
183
|
+
# @return [Array<StatelyDB::Item>, StatelyDB::Token] the list of Items and the token
|
184
|
+
#
|
185
|
+
# @example
|
186
|
+
# client.data.begin_scan(limit: 10, item_types: [MyItem])
|
187
|
+
def begin_scan(limit: 100,
|
188
|
+
item_types: [],
|
189
|
+
total_segments: nil,
|
190
|
+
segment_index: nil)
|
191
|
+
if total_segments.nil? != segment_index.nil?
|
192
|
+
raise StatelyDB::Error.new("total_segments and segment_index must both be set or both be nil",
|
193
|
+
code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
|
194
|
+
stately_code: "InvalidArgument")
|
195
|
+
end
|
196
|
+
req = Stately::Db::BeginScanRequest.new(
|
197
|
+
store_id: @store_id,
|
198
|
+
limit:,
|
199
|
+
filter_condition: item_types.map do |item_type|
|
200
|
+
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
201
|
+
end,
|
202
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID
|
203
|
+
)
|
204
|
+
resp = @stub.begin_scan(req)
|
205
|
+
process_list_response(resp)
|
206
|
+
end
|
207
|
+
|
208
|
+
# continue_scan takes the token from a begin_scan call and returns more results
|
209
|
+
# based on the original request parameters and pagination options.
|
210
|
+
#
|
211
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER OF ITEMS.
|
212
|
+
#
|
213
|
+
# @param token [StatelyDB::Token] the token to continue from
|
214
|
+
# @return [Array<StatelyDB::Item>, StatelyDB::Token] the list of Items and the token
|
215
|
+
#
|
216
|
+
# @example
|
217
|
+
# (items, token) = client.data.begin_scan(limit: 10, item_types: [MyItem])
|
218
|
+
# client.data.continue_scan(token)
|
219
|
+
def continue_scan(token)
|
220
|
+
req = Stately::Db::ContinueScanRequest.new(
|
221
|
+
token_data: token.token_data,
|
222
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID
|
223
|
+
)
|
224
|
+
resp = @stub.continue_scan(req)
|
225
|
+
process_list_response(resp)
|
226
|
+
end
|
227
|
+
|
168
228
|
# Sync a list of Items from a StatelyDB Store.
|
169
229
|
#
|
170
230
|
# @param token [StatelyDB::Token] the token to sync from
|
@@ -331,7 +391,7 @@ module StatelyDB
|
|
331
391
|
def process_list_response(resp)
|
332
392
|
items = []
|
333
393
|
token = nil
|
334
|
-
resp
|
394
|
+
safe_yield_stream(resp) do |r|
|
335
395
|
case r.response
|
336
396
|
when :result
|
337
397
|
r.result.items.map do |result|
|
@@ -360,7 +420,7 @@ module StatelyDB
|
|
360
420
|
updated_outside_list_window_paths = []
|
361
421
|
token = nil
|
362
422
|
is_reset = false
|
363
|
-
resp
|
423
|
+
safe_yield_stream(resp) do |r|
|
364
424
|
case r.response
|
365
425
|
when :result
|
366
426
|
r.result.changed_items.each do |item|
|
data/sig/statelydb.rbi
CHANGED
@@ -297,6 +297,53 @@ module StatelyDB
|
|
297
297
|
sig { params(token: StatelyDB::Token).returns(T.any(T::Array[StatelyDB::Item], StatelyDB::Token)) }
|
298
298
|
def continue_list(token); end
|
299
299
|
|
300
|
+
# Initiates a scan request which will scan over the entire store and apply
|
301
|
+
# the provided filters. This API returns a token that you can pass to
|
302
|
+
# continue_scan to paginate through the result set. This can fail if the
|
303
|
+
# caller does not have permission to read Items.
|
304
|
+
#
|
305
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER
|
306
|
+
# OF ITEMS.
|
307
|
+
#
|
308
|
+
# _@param_ `limit` — the maximum number of items to return
|
309
|
+
#
|
310
|
+
# _@param_ `item_types` — the item types to filter by. The returned items will be instances of one of these types.
|
311
|
+
#
|
312
|
+
# _@param_ `total_segments` — the total number of segments to divide the scan into. Use this when you want to parallelize your operation.
|
313
|
+
#
|
314
|
+
# _@param_ `segment_index` — the index of the segment to scan. Use this when you want to parallelize your operation.
|
315
|
+
#
|
316
|
+
# _@return_ — the list of Items and the token
|
317
|
+
#
|
318
|
+
# ```ruby
|
319
|
+
# client.data.begin_scan(limit: 10, item_types: [MyItem])
|
320
|
+
# ```
|
321
|
+
sig do
|
322
|
+
params(
|
323
|
+
limit: Integer,
|
324
|
+
item_types: T::Array[T.any(Class, String)],
|
325
|
+
total_segments: T.nilable(Integer),
|
326
|
+
segment_index: T.nilable(Integer)
|
327
|
+
).returns(T.any(T::Array[StatelyDB::Item], StatelyDB::Token))
|
328
|
+
end
|
329
|
+
def begin_scan(limit: 100, item_types: [], total_segments: nil, segment_index: nil); end
|
330
|
+
|
331
|
+
# continue_scan takes the token from a begin_scan call and returns more results
|
332
|
+
# based on the original request parameters and pagination options.
|
333
|
+
#
|
334
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER OF ITEMS.
|
335
|
+
#
|
336
|
+
# _@param_ `token` — the token to continue from
|
337
|
+
#
|
338
|
+
# _@return_ — the list of Items and the token
|
339
|
+
#
|
340
|
+
# ```ruby
|
341
|
+
# (items, token) = client.data.begin_scan(limit: 10, item_types: [MyItem])
|
342
|
+
# client.data.continue_scan(token)
|
343
|
+
# ```
|
344
|
+
sig { params(token: StatelyDB::Token).returns(T.any(T::Array[StatelyDB::Item], StatelyDB::Token)) }
|
345
|
+
def continue_scan(token); end
|
346
|
+
|
300
347
|
# Sync a list of Items from a StatelyDB Store.
|
301
348
|
#
|
302
349
|
# _@param_ `token` — the token to sync from
|
@@ -757,49 +804,6 @@ module StatelyDB
|
|
757
804
|
|
758
805
|
# GRPC interceptor to convert errors to StatelyDB::Error
|
759
806
|
class ErrorInterceptor < GRPC::ClientInterceptor
|
760
|
-
# client unary interceptor
|
761
|
-
sig do
|
762
|
-
params(
|
763
|
-
request: T.untyped,
|
764
|
-
call: T.untyped,
|
765
|
-
method: T.untyped,
|
766
|
-
metadata: T.untyped
|
767
|
-
).returns(T.untyped)
|
768
|
-
end
|
769
|
-
def request_response(request:, call:, method:, metadata:); end
|
770
|
-
|
771
|
-
# client streaming interceptor
|
772
|
-
sig do
|
773
|
-
params(
|
774
|
-
requests: T.untyped,
|
775
|
-
call: T.untyped,
|
776
|
-
method: T.untyped,
|
777
|
-
metadata: T.untyped
|
778
|
-
).returns(T.untyped)
|
779
|
-
end
|
780
|
-
def client_streamer(requests:, call:, method:, metadata:); end
|
781
|
-
|
782
|
-
# server streaming interceptor
|
783
|
-
sig do
|
784
|
-
params(
|
785
|
-
request: T.untyped,
|
786
|
-
call: T.untyped,
|
787
|
-
method: T.untyped,
|
788
|
-
metadata: T.untyped
|
789
|
-
).returns(T.untyped)
|
790
|
-
end
|
791
|
-
def server_streamer(request:, call:, method:, metadata:); end
|
792
|
-
|
793
|
-
# bidirectional streaming interceptor
|
794
|
-
sig do
|
795
|
-
params(
|
796
|
-
requests: T.untyped,
|
797
|
-
call: T.untyped,
|
798
|
-
method: T.untyped,
|
799
|
-
metadata: T.untyped
|
800
|
-
).returns(T.untyped)
|
801
|
-
end
|
802
|
-
def bidi_streamer(requests:, call:, method:, metadata:); end
|
803
807
|
end
|
804
808
|
end
|
805
809
|
|
data/sig/statelydb.rbs
CHANGED
@@ -252,6 +252,49 @@ module StatelyDB
|
|
252
252
|
# ```
|
253
253
|
def continue_list: (StatelyDB::Token token) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
|
254
254
|
|
255
|
+
# Initiates a scan request which will scan over the entire store and apply
|
256
|
+
# the provided filters. This API returns a token that you can pass to
|
257
|
+
# continue_scan to paginate through the result set. This can fail if the
|
258
|
+
# caller does not have permission to read Items.
|
259
|
+
#
|
260
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER
|
261
|
+
# OF ITEMS.
|
262
|
+
#
|
263
|
+
# _@param_ `limit` — the maximum number of items to return
|
264
|
+
#
|
265
|
+
# _@param_ `item_types` — the item types to filter by. The returned items will be instances of one of these types.
|
266
|
+
#
|
267
|
+
# _@param_ `total_segments` — the total number of segments to divide the scan into. Use this when you want to parallelize your operation.
|
268
|
+
#
|
269
|
+
# _@param_ `segment_index` — the index of the segment to scan. Use this when you want to parallelize your operation.
|
270
|
+
#
|
271
|
+
# _@return_ — the list of Items and the token
|
272
|
+
#
|
273
|
+
# ```ruby
|
274
|
+
# client.data.begin_scan(limit: 10, item_types: [MyItem])
|
275
|
+
# ```
|
276
|
+
def begin_scan: (
|
277
|
+
?limit: Integer,
|
278
|
+
?item_types: ::Array[(Class | String)],
|
279
|
+
?total_segments: Integer?,
|
280
|
+
?segment_index: Integer?
|
281
|
+
) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
|
282
|
+
|
283
|
+
# continue_scan takes the token from a begin_scan call and returns more results
|
284
|
+
# based on the original request parameters and pagination options.
|
285
|
+
#
|
286
|
+
# WARNING: THIS API CAN BE EXTREMELY EXPENSIVE FOR STORES WITH A LARGE NUMBER OF ITEMS.
|
287
|
+
#
|
288
|
+
# _@param_ `token` — the token to continue from
|
289
|
+
#
|
290
|
+
# _@return_ — the list of Items and the token
|
291
|
+
#
|
292
|
+
# ```ruby
|
293
|
+
# (items, token) = client.data.begin_scan(limit: 10, item_types: [MyItem])
|
294
|
+
# client.data.continue_scan(token)
|
295
|
+
# ```
|
296
|
+
def continue_scan: (StatelyDB::Token token) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
|
297
|
+
|
255
298
|
# Sync a list of Items from a StatelyDB Store.
|
256
299
|
#
|
257
300
|
# _@param_ `token` — the token to sync from
|
@@ -651,37 +694,6 @@ module StatelyDB
|
|
651
694
|
|
652
695
|
# GRPC interceptor to convert errors to StatelyDB::Error
|
653
696
|
class ErrorInterceptor < GRPC::ClientInterceptor
|
654
|
-
# client unary interceptor
|
655
|
-
def request_response: (
|
656
|
-
request: untyped,
|
657
|
-
call: untyped,
|
658
|
-
method: untyped,
|
659
|
-
metadata: untyped
|
660
|
-
) -> untyped
|
661
|
-
|
662
|
-
# client streaming interceptor
|
663
|
-
def client_streamer: (
|
664
|
-
requests: untyped,
|
665
|
-
call: untyped,
|
666
|
-
method: untyped,
|
667
|
-
metadata: untyped
|
668
|
-
) -> untyped
|
669
|
-
|
670
|
-
# server streaming interceptor
|
671
|
-
def server_streamer: (
|
672
|
-
request: untyped,
|
673
|
-
call: untyped,
|
674
|
-
method: untyped,
|
675
|
-
metadata: untyped
|
676
|
-
) -> untyped
|
677
|
-
|
678
|
-
# bidirectional streaming interceptor
|
679
|
-
def bidi_streamer: (
|
680
|
-
requests: untyped,
|
681
|
-
call: untyped,
|
682
|
-
method: untyped,
|
683
|
-
metadata: untyped
|
684
|
-
) -> untyped
|
685
697
|
end
|
686
698
|
end
|
687
699
|
|
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.
|
4
|
+
version: 0.19.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: 2025-03-
|
11
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|