statelydb 0.2.1 → 0.4.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/api/db/delete_pb.rb +1 -1
- data/lib/api/db/get_pb.rb +1 -1
- data/lib/api/db/list_pb.rb +1 -1
- data/lib/api/db/put_pb.rb +1 -1
- data/lib/api/db/scan_root_paths_pb.rb +1 -1
- data/lib/api/db/transaction_pb.rb +1 -1
- data/lib/common/net/conn.rb +2 -5
- data/lib/key_path.rb +2 -2
- data/lib/stately_codes.rb +42 -42
- data/lib/statelydb.rb +51 -12
- data/lib/token.rb +2 -2
- data/lib/transaction/transaction.rb +13 -8
- 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: 9da53da8635a6ab8f8e30bf199d0b4fe353319888398d8ec524e3b3d7384eae5
|
4
|
+
data.tar.gz: c09b521842ffaa90a6f441328ac470af5ae8f11579058fa88d09f32fd32186fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2629a952686bc0ef0b7e46f8f826430411f8ea6569c454afd702805e53424c15b456ccb5783cdb1691a196b88f488ccde4489f04fdaaa26f1dee24f4eb1bb0
|
7
|
+
data.tar.gz: c43a2b8013e2756b3605511dca167b0197b8cea5bbf83c0ef63b2ca6fbaa99ed07c1c54a5f4b48e20fc3c126d91d57c041508bd51c67ccc717299c3d8f59556f
|
data/lib/api/db/delete_pb.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
require 'google/protobuf'
|
6
6
|
|
7
7
|
|
8
|
-
descriptor_data = "\n\x0f\x64\x62/delete.proto\x12\nstately.db\"\
|
8
|
+
descriptor_data = "\n\x0f\x64\x62/delete.proto\x12\nstately.db\"\x8e\x01\n\rDeleteRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\x30\n\x07\x64\x65letes\x18\x03 \x03(\x0b\x32\x16.stately.db.DeleteItemR\x07\x64\x65letes\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionIdJ\x04\x08\x04\x10\x05\"\'\n\nDeleteItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPath\"/\n\x0c\x44\x65leteResult\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathJ\x04\x08\x02\x10\x03\"D\n\x0e\x44\x65leteResponse\x12\x32\n\x07results\x18\x01 \x03(\x0b\x32\x18.stately.db.DeleteResultR\x07resultsBf\n\x0e\x63om.stately.dbB\x0b\x44\x65leteProtoP\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)
|
data/lib/api/db/get_pb.rb
CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
require 'db/item_pb'
|
8
8
|
|
9
9
|
|
10
|
-
descriptor_data = "\n\x0c\x64\x62/get.proto\x12\nstately.db\x1a\rdb/item.proto\"\
|
10
|
+
descriptor_data = "\n\x0c\x64\x62/get.proto\x12\nstately.db\x1a\rdb/item.proto\"\xa3\x01\n\nGetRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04gets\x18\x02 \x03(\x0b\x32\x13.stately.db.GetItemR\x04gets\x12\x1f\n\x0b\x61llow_stale\x18\x03 \x01(\x08R\nallowStale\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionIdJ\x04\x08\x04\x10\x05\"$\n\x07GetItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPath\"5\n\x0bGetResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05itemsBc\n\x0e\x63om.stately.dbB\x08GetProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
12
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
data/lib/api/db/list_pb.rb
CHANGED
@@ -9,7 +9,7 @@ require 'db/item_property_pb'
|
|
9
9
|
require 'db/list_token_pb'
|
10
10
|
|
11
11
|
|
12
|
-
descriptor_data = "\n\rdb/list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\x13\x64\x62/list_token.proto\"\
|
12
|
+
descriptor_data = "\n\rdb/list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\x13\x64\x62/list_token.proto\"\xbd\x02\n\x10\x42\x65ginListRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12&\n\x0fkey_path_prefix\x18\x02 \x01(\tR\rkeyPathPrefix\x12\x14\n\x05limit\x18\x03 \x01(\rR\x05limit\x12\x1f\n\x0b\x61llow_stale\x18\x04 \x01(\x08R\nallowStale\x12\x41\n\rsort_property\x18\x05 \x01(\x0e\x32\x1c.stately.db.SortablePropertyR\x0csortProperty\x12@\n\x0esort_direction\x18\x06 \x01(\x0e\x32\x19.stately.db.SortDirectionR\rsortDirection\x12*\n\x11schema_version_id\x18\x07 \x01(\rR\x0fschemaVersionId\"\x8b\x01\n\x0cListResponse\x12\x37\n\x06result\x18\x01 \x01(\x0b\x32\x1d.stately.db.ListPartialResultH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x02 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\";\n\x11ListPartialResult\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05items\";\n\x0cListFinished\x12+\n\x05token\x18\x01 \x01(\x0b\x32\x15.stately.db.ListTokenR\x05token*8\n\rSortDirection\x12\x12\n\x0eSORT_ASCENDING\x10\x00\x12\x13\n\x0fSORT_DESCENDING\x10\x01\x42\x64\n\x0e\x63om.stately.dbB\tListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
13
13
|
|
14
14
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
15
15
|
pool.add_serialized_file(descriptor_data)
|
data/lib/api/db/put_pb.rb
CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
require 'db/item_pb'
|
8
8
|
|
9
9
|
|
10
|
-
descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"
|
10
|
+
descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"|\n\nPutRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04puts\x18\x02 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\x12*\n\x11schema_version_id\x18\x03 \x01(\rR\x0fschemaVersionId\"/\n\x07PutItem\x12$\n\x04item\x18\x01 \x01(\x0b\x32\x10.stately.db.ItemR\x04item\"5\n\x0bPutResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05itemsBc\n\x0e\x63om.stately.dbB\x08PutProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
12
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
require 'google/protobuf'
|
6
6
|
|
7
7
|
|
8
|
-
descriptor_data = "\n\x18\x64\x62/scan_root_paths.proto\x12\nstately.db\"
|
8
|
+
descriptor_data = "\n\x18\x64\x62/scan_root_paths.proto\x12\nstately.db\"\x9e\x01\n\x14ScanRootPathsRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\x14\n\x05limit\x18\x02 \x01(\rR\x05limit\x12)\n\x10pagination_token\x18\x03 \x01(\x0cR\x0fpaginationToken\x12*\n\x11schema_version_id\x18\x04 \x01(\rR\x0fschemaVersionId\"|\n\x15ScanRootPathsResponse\x12\x38\n\x07results\x18\x01 \x03(\x0b\x32\x1e.stately.db.ScanRootPathResultR\x07results\x12)\n\x10pagination_token\x18\x02 \x01(\x0cR\x0fpaginationToken\"/\n\x12ScanRootPathResult\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathBm\n\x0e\x63om.stately.dbB\x12ScanRootPathsProtoP\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)
|
@@ -14,7 +14,7 @@ require 'db/put_pb'
|
|
14
14
|
require 'google/protobuf/empty_pb'
|
15
15
|
|
16
16
|
|
17
|
-
descriptor_data = "\n\x14\x64\x62/transaction.proto\x12\nstately.db\x1a\x16\x64\x62/continue_list.proto\x1a\x0f\x64\x62/delete.proto\x1a\x0c\x64\x62/get.proto\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\rdb/list.proto\x1a\x0c\x64\x62/put.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x9f\x04\n\x12TransactionRequest\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x34\n\x05\x62\x65gin\x18\x02 \x01(\x0b\x32\x1c.stately.db.TransactionBeginH\x00R\x05\x62\x65gin\x12\x39\n\tget_items\x18\x03 \x01(\x0b\x32\x1a.stately.db.TransactionGetH\x00R\x08getItems\x12\x41\n\nbegin_list\x18\x04 \x01(\x0b\x32 .stately.db.TransactionBeginListH\x00R\tbeginList\x12J\n\rcontinue_list\x18\x05 \x01(\x0b\x32#.stately.db.TransactionContinueListH\x00R\x0c\x63ontinueList\x12\x39\n\tput_items\x18\x06 \x01(\x0b\x32\x1a.stately.db.TransactionPutH\x00R\x08putItems\x12\x42\n\x0c\x64\x65lete_items\x18\x07 \x01(\x0b\x32\x1d.stately.db.TransactionDeleteH\x00R\x0b\x64\x65leteItems\x12\x30\n\x06\x63ommit\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x06\x63ommit\x12.\n\x05\x61\x62ort\x18\t \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x05\x61\x62ortB\t\n\x07\x63ommand\"\xc8\x02\n\x13TransactionResponse\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x45\n\x0bget_results\x18\x02 \x01(\x0b\x32\".stately.db.TransactionGetResponseH\x00R\ngetResults\x12\x38\n\x07put_ack\x18\x03 \x01(\x0b\x32\x1d.stately.db.TransactionPutAckH\x00R\x06putAck\x12H\n\x0clist_results\x18\x04 \x01(\x0b\x32#.stately.db.TransactionListResponseH\x00R\x0blistResults\x12=\n\x08\x66inished\x18\x05 \x01(\x0b\x32\x1f.stately.db.TransactionFinishedH\x00R\x08\x66inishedB\x08\n\x06result\"
|
17
|
+
descriptor_data = "\n\x14\x64\x62/transaction.proto\x12\nstately.db\x1a\x16\x64\x62/continue_list.proto\x1a\x0f\x64\x62/delete.proto\x1a\x0c\x64\x62/get.proto\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\rdb/list.proto\x1a\x0c\x64\x62/put.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x9f\x04\n\x12TransactionRequest\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x34\n\x05\x62\x65gin\x18\x02 \x01(\x0b\x32\x1c.stately.db.TransactionBeginH\x00R\x05\x62\x65gin\x12\x39\n\tget_items\x18\x03 \x01(\x0b\x32\x1a.stately.db.TransactionGetH\x00R\x08getItems\x12\x41\n\nbegin_list\x18\x04 \x01(\x0b\x32 .stately.db.TransactionBeginListH\x00R\tbeginList\x12J\n\rcontinue_list\x18\x05 \x01(\x0b\x32#.stately.db.TransactionContinueListH\x00R\x0c\x63ontinueList\x12\x39\n\tput_items\x18\x06 \x01(\x0b\x32\x1a.stately.db.TransactionPutH\x00R\x08putItems\x12\x42\n\x0c\x64\x65lete_items\x18\x07 \x01(\x0b\x32\x1d.stately.db.TransactionDeleteH\x00R\x0b\x64\x65leteItems\x12\x30\n\x06\x63ommit\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x06\x63ommit\x12.\n\x05\x61\x62ort\x18\t \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x05\x61\x62ortB\t\n\x07\x63ommand\"\xc8\x02\n\x13TransactionResponse\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x45\n\x0bget_results\x18\x02 \x01(\x0b\x32\".stately.db.TransactionGetResponseH\x00R\ngetResults\x12\x38\n\x07put_ack\x18\x03 \x01(\x0b\x32\x1d.stately.db.TransactionPutAckH\x00R\x06putAck\x12H\n\x0clist_results\x18\x04 \x01(\x0b\x32#.stately.db.TransactionListResponseH\x00R\x0blistResults\x12=\n\x08\x66inished\x18\x05 \x01(\x0b\x32\x1f.stately.db.TransactionFinishedH\x00R\x08\x66inishedB\x08\n\x06result\"Y\n\x10TransactionBegin\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12*\n\x11schema_version_id\x18\x02 \x01(\rR\x0fschemaVersionId\"9\n\x0eTransactionGet\x12\'\n\x04gets\x18\x01 \x03(\x0b\x32\x13.stately.db.GetItemR\x04gets\"\xd9\x01\n\x14TransactionBeginList\x12&\n\x0fkey_path_prefix\x18\x01 \x01(\tR\rkeyPathPrefix\x12\x14\n\x05limit\x18\x02 \x01(\rR\x05limit\x12\x41\n\rsort_property\x18\x03 \x01(\x0e\x32\x1c.stately.db.SortablePropertyR\x0csortProperty\x12@\n\x0esort_direction\x18\x04 \x01(\x0e\x32\x19.stately.db.SortDirectionR\rsortDirection\"y\n\x17TransactionContinueList\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12?\n\tdirection\x18\x04 \x01(\x0e\x32!.stately.db.ContinueListDirectionR\tdirection\"9\n\x0eTransactionPut\x12\'\n\x04puts\x18\x01 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\"E\n\x11TransactionDelete\x12\x30\n\x07\x64\x65letes\x18\x01 \x03(\x0b\x32\x16.stately.db.DeleteItemR\x07\x64\x65letes\"@\n\x16TransactionGetResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05items\"D\n\x0bGeneratedID\x12\x14\n\x04uint\x18\x01 \x01(\x04H\x00R\x04uint\x12\x16\n\x05\x62ytes\x18\x02 \x01(\x0cH\x00R\x05\x62ytesB\x07\n\x05value\"Q\n\x11TransactionPutAck\x12<\n\rgenerated_ids\x18\x01 \x03(\x0b\x32\x17.stately.db.GeneratedIDR\x0cgeneratedIds\"\x96\x01\n\x17TransactionListResponse\x12\x37\n\x06result\x18\x01 \x01(\x0b\x32\x1d.stately.db.ListPartialResultH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x02 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\"\xa7\x01\n\x13TransactionFinished\x12\x1c\n\tcommitted\x18\x01 \x01(\x08R\tcommitted\x12\x31\n\x0bput_results\x18\x02 \x03(\x0b\x32\x10.stately.db.ItemR\nputResults\x12?\n\x0e\x64\x65lete_results\x18\x03 \x03(\x0b\x32\x18.stately.db.DeleteResultR\rdeleteResultsBk\n\x0e\x63om.stately.dbB\x10TransactionProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
18
18
|
|
19
19
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
20
20
|
pool.add_serialized_file(descriptor_data)
|
data/lib/common/net/conn.rb
CHANGED
@@ -10,7 +10,7 @@ module StatelyDB
|
|
10
10
|
# Create a new gRPC channel
|
11
11
|
# @param [String] endpoint The endpoint to connect to
|
12
12
|
# @return [GRPC::Core::Channel] The new channel
|
13
|
-
def self.new_channel(endpoint:
|
13
|
+
def self.new_channel(endpoint:)
|
14
14
|
endpoint_uri = URI(endpoint)
|
15
15
|
creds = GRPC::Core::ChannelCredentials.new
|
16
16
|
call_creds = GRPC::Core::CallCredentials.new(proc {})
|
@@ -30,10 +30,7 @@ module StatelyDB
|
|
30
30
|
# while still successfully reading the metadata because only the soft
|
31
31
|
# limit was exceeded.
|
32
32
|
"grpc.max_metadata_size" => 8192 * 2,
|
33
|
-
"grpc.absolute_max_metadata_size" => 8192 * 2
|
34
|
-
# allow unlimited receive message length while we debug a flaky test
|
35
|
-
# https://app.clickup.com/t/8689hem75
|
36
|
-
"grpc.max_receive_message_length" => -1
|
33
|
+
"grpc.absolute_max_metadata_size" => 8192 * 2
|
37
34
|
}, creds)
|
38
35
|
end
|
39
36
|
end
|
data/lib/key_path.rb
CHANGED
@@ -10,7 +10,7 @@ module StatelyDB
|
|
10
10
|
|
11
11
|
# Appends a new path segment.
|
12
12
|
# @param [String] namespace
|
13
|
-
# @param [String] identifier
|
13
|
+
# @param [String, StatelyDB::UUID, #to_s] identifier
|
14
14
|
# @return [KeyPath]
|
15
15
|
def with(namespace, identifier = nil)
|
16
16
|
if identifier.nil?
|
@@ -38,7 +38,7 @@ module StatelyDB
|
|
38
38
|
|
39
39
|
# Appends a new path segment.
|
40
40
|
# @param [String] namespace
|
41
|
-
# @param [String] identifier
|
41
|
+
# @param [String, StatelyDB::UUID, #to_s] identifier
|
42
42
|
# @return [KeyPath]
|
43
43
|
#
|
44
44
|
# @example
|
data/lib/stately_codes.rb
CHANGED
@@ -1,46 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module StatelyCode
|
4
|
-
# StoreRequestLimitExceeded indicates that an attempt to modify a Store has
|
5
|
-
# been temporarily rejected due to exceeding global modification limits.
|
6
|
-
# StatelyDB has been notified about this error and will take necessary
|
7
|
-
# actions to correct it. In the event that the issue has not been resolved,
|
8
|
-
# please contact support.
|
9
|
-
#
|
10
|
-
# - Retryable? Yes.
|
11
|
-
STORE_REQUEST_LIMIT_EXCEEDED = "StoreRequestLimitExceeded"
|
12
|
-
|
13
|
-
# StoreThroughputExceeded indicates that the underlying Store does not have
|
14
|
-
# resources to complete the request. This may indicate a request rate is too
|
15
|
-
# high to a specific Group or that a sudden burst of traffic has exceeded a
|
16
|
-
# Store's provisioned capacity.
|
17
|
-
#
|
18
|
-
# - Retryable? Yes.
|
19
|
-
# With an exponential backoff.
|
20
|
-
STORE_THROUGHPUT_EXCEEDED = "StoreThroughputExceeded"
|
21
|
-
|
22
|
-
# ConditionalCheckFailed indicates that conditions provided to perform an
|
23
|
-
# operation were not met. For example, a condition to write an item only if
|
24
|
-
# it does not already exist. In the future StatelyDB may provide more
|
25
|
-
# information about the failed condition; if this feature is a blocker,
|
26
|
-
# please contact support.
|
27
|
-
#
|
28
|
-
# - Retryable? No.
|
29
|
-
# Typically a conditional check failure is not retryable
|
30
|
-
# unless the conditions for the operation are changed.
|
31
|
-
CONDITIONAL_CHECK_FAILED = "ConditionalCheckFailed"
|
32
|
-
|
33
|
-
# NonRecoverableTransaction indicates that conditions required for the
|
34
|
-
# transaction to succeed are not possible to meet with the current state of
|
35
|
-
# the system. This can occur when an Item has more than one key-path, and is
|
36
|
-
# written with a "must not exist" condition (e.g. with ID Generation on one
|
37
|
-
# of the keys) but another keys already maps to an existing item in the
|
38
|
-
# store. Permitting such a write would result in conflicting state; two
|
39
|
-
# independent records with aliases pointing to the same item.
|
40
|
-
#
|
41
|
-
# - Retryable? No.
|
42
|
-
NON_RECOVERABLE_TRANSACTION = "NonRecoverableTransaction"
|
43
|
-
|
44
4
|
# ConcurrentModification indicates the current transaction was aborted
|
45
5
|
# because of a non-serializable interaction with another transaction was
|
46
6
|
# detected, a stale read was detected, or because attempts to resolve an
|
@@ -65,15 +25,55 @@ module StatelyCode
|
|
65
25
|
# 3. A read or list operation detected that underlying data has changed
|
66
26
|
# since the transaction began.
|
67
27
|
#
|
68
|
-
# - Retryable
|
28
|
+
# - Retryable
|
69
29
|
# This error is immediately retryable.
|
70
30
|
CONCURRENT_MODIFICATION = "ConcurrentModification"
|
71
31
|
|
32
|
+
# ConditionalCheckFailed indicates that conditions provided to perform an
|
33
|
+
# operation were not met. For example, a condition to write an item only if
|
34
|
+
# it does not already exist. In the future StatelyDB may provide more
|
35
|
+
# information about the failed condition; if this feature is a blocker,
|
36
|
+
# please contact support.
|
37
|
+
#
|
38
|
+
# - Not Retryable
|
39
|
+
# Typically a conditional check failure is not retryable
|
40
|
+
# unless the conditions for the operation are changed.
|
41
|
+
CONDITIONAL_CHECK_FAILED = "ConditionalCheckFailed"
|
42
|
+
|
43
|
+
# NonRecoverableTransaction indicates that conditions required for the
|
44
|
+
# transaction to succeed are not possible to meet with the current state of
|
45
|
+
# the system. This can occur when an Item has more than one key-path, and is
|
46
|
+
# written with a "must not exist" condition (e.g. with ID Generation on one
|
47
|
+
# of the keys) but another keys already maps to an existing item in the
|
48
|
+
# store. Permitting such a write would result in conflicting state; two
|
49
|
+
# independent records with aliases pointing to the same item.
|
50
|
+
#
|
51
|
+
# - Not Retryable
|
52
|
+
NON_RECOVERABLE_TRANSACTION = "NonRecoverableTransaction"
|
53
|
+
|
72
54
|
# StoreInUse indicates that the underlying Store is currently in being
|
73
55
|
# updated and cannot be modified until the operation in progress has
|
74
56
|
# completed.
|
75
57
|
#
|
76
|
-
# - Retryable
|
58
|
+
# - Retryable
|
77
59
|
# This can be retried with backoff.
|
78
60
|
STORE_IN_USE = "StoreInUse"
|
61
|
+
|
62
|
+
# StoreRequestLimitExceeded indicates that an attempt to modify a Store has
|
63
|
+
# been temporarily rejected due to exceeding global modification limits.
|
64
|
+
# StatelyDB has been notified about this error and will take necessary
|
65
|
+
# actions to correct it. In the event that the issue has not been resolved,
|
66
|
+
# please contact support.
|
67
|
+
#
|
68
|
+
# - Retryable
|
69
|
+
STORE_REQUEST_LIMIT_EXCEEDED = "StoreRequestLimitExceeded"
|
70
|
+
|
71
|
+
# StoreThroughputExceeded indicates that the underlying Store does not have
|
72
|
+
# resources to complete the request. This may indicate a request rate is too
|
73
|
+
# high to a specific Group or that a sudden burst of traffic has exceeded a
|
74
|
+
# Store's provisioned capacity.
|
75
|
+
#
|
76
|
+
# - Retryable
|
77
|
+
# With an exponential backoff.
|
78
|
+
STORE_THROUGHPUT_EXCEEDED = "StoreThroughputExceeded"
|
79
79
|
end
|
data/lib/statelydb.rb
CHANGED
@@ -29,14 +29,20 @@ module StatelyDB
|
|
29
29
|
# @param store_id [Integer] the StatelyDB to use for all operations with this client.
|
30
30
|
# @param schema [Module] the schema module to use for mapping StatelyDB Items.
|
31
31
|
# @param token_provider [Common::Auth::TokenProvider] the token provider to use for authentication.
|
32
|
-
# @param
|
32
|
+
# @param endpoint [String] the endpoint to connect to.
|
33
|
+
# @param region [String] the region to connect to.
|
33
34
|
def initialize(store_id: nil,
|
34
35
|
schema: StatelyDB::Types,
|
35
36
|
token_provider: Common::Auth::Auth0TokenProvider.new,
|
36
|
-
|
37
|
+
endpoint: nil,
|
38
|
+
region: nil)
|
37
39
|
raise "store_id is required" if store_id.nil?
|
38
40
|
raise "schema is required" if schema.nil?
|
39
41
|
|
42
|
+
endpoint = self.class.make_endpoint(endpoint:, region:)
|
43
|
+
|
44
|
+
channel = Common::Net.new_channel(endpoint:)
|
45
|
+
|
40
46
|
auth_interceptor = Common::Auth::Interceptor.new(token_provider:)
|
41
47
|
error_interceptor = Common::ErrorInterceptor.new
|
42
48
|
|
@@ -74,9 +80,9 @@ module StatelyDB
|
|
74
80
|
resp.first
|
75
81
|
end
|
76
82
|
|
77
|
-
# Fetch a batch of Items from a StatelyDB Store at the given key_paths.
|
83
|
+
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given key_paths.
|
78
84
|
#
|
79
|
-
# @param key_paths [String, Array<String>] the paths to the items
|
85
|
+
# @param key_paths [String, Array<String>] the paths to the items. Max 100 key paths.
|
80
86
|
# @return [Array<StatelyDB::Item>, NilClass] the items or nil if not found
|
81
87
|
# @raise [StatelyDB::Error] if the parameters are invalid or if the item is not found
|
82
88
|
#
|
@@ -86,6 +92,7 @@ module StatelyDB
|
|
86
92
|
key_paths = Array(key_paths).flatten
|
87
93
|
req = Stately::Db::GetRequest.new(
|
88
94
|
store_id: @store_id,
|
95
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID,
|
89
96
|
gets:
|
90
97
|
key_paths.map { |key_path| Stately::Db::GetItem.new(key_path: String(key_path)) },
|
91
98
|
allow_stale: @allow_stale
|
@@ -119,7 +126,8 @@ module StatelyDB
|
|
119
126
|
limit:,
|
120
127
|
sort_property:,
|
121
128
|
sort_direction:,
|
122
|
-
allow_stale: @allow_stale
|
129
|
+
allow_stale: @allow_stale,
|
130
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID
|
123
131
|
)
|
124
132
|
resp = @stub.begin_list(req)
|
125
133
|
process_list_response(resp)
|
@@ -171,9 +179,9 @@ module StatelyDB
|
|
171
179
|
resp.first
|
172
180
|
end
|
173
181
|
|
174
|
-
# Put a batch of Items into a StatelyDB Store.
|
182
|
+
# Put a batch of up to 50 Items into a StatelyDB Store.
|
175
183
|
#
|
176
|
-
# @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store
|
184
|
+
# @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store. Max 50 items.
|
177
185
|
# @return [Array<StatelyDB::Item>] the items that were stored
|
178
186
|
#
|
179
187
|
# @example
|
@@ -182,6 +190,7 @@ module StatelyDB
|
|
182
190
|
items = Array(items).flatten
|
183
191
|
req = Stately::Db::PutRequest.new(
|
184
192
|
store_id: @store_id,
|
193
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID,
|
185
194
|
puts: items.map do |item|
|
186
195
|
Stately::Db::PutItem.new(
|
187
196
|
item: item.send("marshal_stately")
|
@@ -195,9 +204,9 @@ module StatelyDB
|
|
195
204
|
end
|
196
205
|
end
|
197
206
|
|
198
|
-
# Delete
|
207
|
+
# Delete up to 50 Items from a StatelyDB Store at the given key_paths.
|
199
208
|
#
|
200
|
-
# @param key_paths [String, Array<String>] the paths to the items
|
209
|
+
# @param key_paths [String, Array<String>] the paths to the items. Max 50 key paths.
|
201
210
|
# @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
|
202
211
|
# @raise [StatelyDB::Error::NotFound] if the item is not found
|
203
212
|
# @return [void] nil
|
@@ -208,6 +217,7 @@ module StatelyDB
|
|
208
217
|
key_paths = Array(key_paths).flatten
|
209
218
|
req = Stately::Db::DeleteRequest.new(
|
210
219
|
store_id: @store_id,
|
220
|
+
schema_version_id: @schema::SCHEMA_VERSION_ID,
|
211
221
|
deletes: key_paths.map { |key_path| Stately::Db::DeleteItem.new(key_path: String(key_path)) }
|
212
222
|
)
|
213
223
|
@stub.delete(req)
|
@@ -247,6 +257,25 @@ module StatelyDB
|
|
247
257
|
raise
|
248
258
|
end
|
249
259
|
|
260
|
+
# Construct the API endpoint from the region and endpoint.
|
261
|
+
# If the endpoint is provided, it will be returned as-is.
|
262
|
+
# If the region is provided and the endpoint is not,
|
263
|
+
# then the region-specific endpoint will be returned.
|
264
|
+
# If neither the region nor the endpoint is provided,
|
265
|
+
# then the default endpoint will be returned.
|
266
|
+
#
|
267
|
+
# @param endpoint [String] the endpoint to connect to
|
268
|
+
# @param region [Region] the region to connect to
|
269
|
+
# @return [String] the constructed endpoint
|
270
|
+
def self.make_endpoint(endpoint: nil, region: nil)
|
271
|
+
return endpoint unless endpoint.nil?
|
272
|
+
return "https://api.stately.cloud" if region.nil?
|
273
|
+
|
274
|
+
region = region.sub("aws-", "") if region.start_with?("aws-")
|
275
|
+
|
276
|
+
"https://#{region}.aws.api.stately.cloud"
|
277
|
+
end
|
278
|
+
|
250
279
|
private
|
251
280
|
|
252
281
|
# Process a list response from begin_list or continue_list
|
@@ -283,6 +312,7 @@ module StatelyDB
|
|
283
312
|
def process_sync_response(resp)
|
284
313
|
changed_items = []
|
285
314
|
deleted_item_paths = []
|
315
|
+
updated_outside_list_window_paths = []
|
286
316
|
token = nil
|
287
317
|
is_reset = false
|
288
318
|
resp.each do |r|
|
@@ -294,6 +324,9 @@ module StatelyDB
|
|
294
324
|
r.result.deleted_items.each do |item|
|
295
325
|
deleted_item_paths << item.key_path
|
296
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
|
297
330
|
when :reset
|
298
331
|
is_reset = true
|
299
332
|
when :finished
|
@@ -303,7 +336,7 @@ module StatelyDB
|
|
303
336
|
can_sync: raw_token.can_sync)
|
304
337
|
end
|
305
338
|
end
|
306
|
-
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:)
|
307
340
|
end
|
308
341
|
end
|
309
342
|
|
@@ -311,18 +344,24 @@ module StatelyDB
|
|
311
344
|
#
|
312
345
|
# @attr_reader changed_items [Array<StatelyDB::Item>] the items that were changed
|
313
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.
|
314
350
|
# @attr_reader is_reset [Boolean] whether the sync operation reset the token
|
315
351
|
# @attr_reader token [StatelyDB::Token] the token to continue from
|
316
352
|
class SyncResult
|
317
|
-
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
|
318
354
|
|
319
355
|
# @param changed_items [Array<StatelyDB::Item>] the items that were changed
|
320
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
|
321
359
|
# @param is_reset [Boolean] whether the sync operation reset the token
|
322
360
|
# @param token [StatelyDB::Token] the token to continue from
|
323
|
-
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:)
|
324
362
|
@changed_items = changed_items
|
325
363
|
@deleted_item_paths = deleted_item_paths
|
364
|
+
@updated_outside_list_window_paths = updated_outside_list_window_paths
|
326
365
|
@is_reset = is_reset
|
327
366
|
@token = token
|
328
367
|
end
|
data/lib/token.rb
CHANGED
@@ -4,8 +4,8 @@ module StatelyDB
|
|
4
4
|
# The Token type contains a continuation token for list and sync operations along with metadata about the ability
|
5
5
|
# to sync or continue listing based on the last operation performed.
|
6
6
|
#
|
7
|
-
# Ths StatelyDB SDK vends this Token type for list and sync operations.
|
8
|
-
# type directly.
|
7
|
+
# Ths StatelyDB SDK vends this Token type for list and sync operations.
|
8
|
+
# Consumers should not need to construct this type directly.
|
9
9
|
class Token
|
10
10
|
# @!visibility private
|
11
11
|
attr_accessor :token_data
|
@@ -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(
|
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
|
@@ -189,10 +192,12 @@ module StatelyDB
|
|
189
192
|
resp.first
|
190
193
|
end
|
191
194
|
|
192
|
-
# Fetch a batch of Items from a StatelyDB Store at the given
|
193
|
-
# inside a
|
195
|
+
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given
|
196
|
+
# key_paths. Note that Items need to exist before being retrieved inside a
|
197
|
+
# transaction.
|
194
198
|
#
|
195
|
-
# @param key_paths [String, Array<String>] the paths to the items
|
199
|
+
# @param key_paths [String, Array<String>] the paths to the items. Max 100
|
200
|
+
# key paths.
|
196
201
|
# @return [Array<StatelyDB::Item>] the items
|
197
202
|
# @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
|
198
203
|
# @raise [StatelyDB::Error::NotFound] if the item is not found
|
@@ -234,11 +239,11 @@ module StatelyDB
|
|
234
239
|
resp.first
|
235
240
|
end
|
236
241
|
|
237
|
-
# Put a batch of Items into a StatelyDB Store. Results are not returned until the transaction is
|
242
|
+
# Put a batch of up to 50 Items into a StatelyDB Store. Results are not returned until the transaction is
|
238
243
|
# committed and will be available in the Result object returned by commit. A list of identifiers
|
239
244
|
# for the items will be returned while inside the transaction block.
|
240
245
|
#
|
241
|
-
# @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store
|
246
|
+
# @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store. Max 50 items.
|
242
247
|
# @return [Array<StatelyDB::UUID, String, Integer, nil>] the ids of the items
|
243
248
|
#
|
244
249
|
# @example
|
@@ -274,10 +279,10 @@ module StatelyDB
|
|
274
279
|
end
|
275
280
|
end
|
276
281
|
|
277
|
-
# Delete
|
282
|
+
# Delete up to 50 Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
|
278
283
|
# committed and will be available in the Result object returned by commit.
|
279
284
|
#
|
280
|
-
# @param key_paths [String, Array<String>] the paths to the items
|
285
|
+
# @param key_paths [String, Array<String>] the paths to the items. Max 50 key paths.
|
281
286
|
# @return [void] nil
|
282
287
|
#
|
283
288
|
# Example:
|
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.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-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|