statelydb 0.2.0 → 0.3.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: 712caae72447e18fda3456a1b70a9d1c6067994c9d084e715b6b0c0b92bd583f
4
- data.tar.gz: 993afea8590f64f6a06c414508052aa42291654a1379e44da31b4da686d38f84
3
+ metadata.gz: 8481aaa31dca18c89b20c17cea4e413165e0aa6677c5ba3eb522780f9f327559
4
+ data.tar.gz: cdbfd5503bc8d8882a47b3b9fbc59c591477957572d66539c8841c55d8ad2ec4
5
5
  SHA512:
6
- metadata.gz: f02e87c5fa5bf878b8a4421d3950a9a967dc3239f43f015ee670b1fb44ece8361f9a7314d224bd1f13ab258e002187d9aa5a6e69477781064d6c7493c33e2687
7
- data.tar.gz: 270c30a9b29b264faf23ba1b842993bcb1a5d271b8cebcc6055980c8d311e180b92b617ca26fc29d0223b0c60f7a9b522df9dad1db03b591b6f9208c5aa757b5
6
+ metadata.gz: 1484b054ae70123705dcb70911019173d766e16dc7c748e00ac7409b26617d87e3131d11ca3d0a65b91081f7371a787818993e81ebc6af232c9dc1f685ac951a
7
+ data.tar.gz: 85acbaf93fadc0c5928f47ef41d534ff93ea1b2ecdd08021fb78df456bc5451a8a14e889b8de539df72f32c81f05c1d5431762cd69309a408a80bc5e3e6b4342
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # StatelyDB SDK for Ruby
2
+
3
+ This is the Ruby SDK for [StatelyDB](https://stately.cloud).
4
+
5
+ ### Getting started:
6
+
7
+ ##### Disclaimer:
8
+
9
+ We're still in an invite-only preview mode - if you're interested, please reach out to [preview@stately.cloud](mailto:preview@stately.cloud?subject=Early%20Access%20Program).
10
+
11
+ When you join the preview program, we'll set you up with a few bits of information:
12
+
13
+ 1. `STATELY_CLIENT_ID` - a client identifier so we know what client you are.
14
+ 2. `STATELY_CLIENT_SECRET` - a sensitive secret that lets your applications authenticate with the API.
15
+ 3. A store ID that identifies which store in your organization you're using.
16
+ 4. Access to our in-depth [Getting Started Guide].
17
+
18
+ Begin by following our [Getting Started Guide] which will help you define, generate, and publish a DB schema so that it can be used.
19
+
20
+ ##### Install the SDK
21
+
22
+ ```sh
23
+ gem install statelydb
24
+ ```
25
+
26
+
27
+ ### Usage:
28
+
29
+ Create an authenticated client, then import your item types from your generated schema module and use the client!
30
+
31
+ ```ruby
32
+ require 'statelydb'
33
+
34
+ def put_my_item
35
+ # Create a client. This will use the environment variables
36
+ # STATELY_CLIENT_ID and STATELY_CLIENT_SECRET for your client.
37
+ client = StatelyDB::Client.new(store_id: <my-store-id>)
38
+
39
+ # Instantiate an item from your schema
40
+ item = StatelyDB::Types::MyItem.new(name: "Jane Doe")
41
+
42
+ # put and get the item!
43
+ put_result = client.put(item)
44
+ get_result = client.get(StatelyDB::KeyPath.with("name", "Jane Doe"))
45
+ puts put_result == get_result # true
46
+ ```
47
+
48
+ ---
49
+
50
+ [Getting Started Guide]: https://preview-docs.stately.cloud/guides/getting-started/
51
+ [Defining Schema]: https://preview-docs.stately.cloud/guides/defining-schema/
@@ -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\"b\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\x65letesJ\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"
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\"w\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\nallowStaleJ\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"
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)
@@ -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\"\x91\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\"\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"
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\"P\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\"/\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"
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\"r\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\"|\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"
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\"-\n\x10TransactionBegin\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\"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"
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)
@@ -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: "https://api.stately.cloud")
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? Yes.
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? Yes.
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 channel [GRPC::Core::Channel] the gRPC channel to use for communication.
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
- channel: Common::Net.new_channel)
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
  #
@@ -171,9 +177,9 @@ module StatelyDB
171
177
  resp.first
172
178
  end
173
179
 
174
- # Put a batch of Items into a StatelyDB Store.
180
+ # Put a batch of up to 50 Items into a StatelyDB Store.
175
181
  #
176
- # @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store
182
+ # @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store. Max 50 items.
177
183
  # @return [Array<StatelyDB::Item>] the items that were stored
178
184
  #
179
185
  # @example
@@ -195,9 +201,9 @@ module StatelyDB
195
201
  end
196
202
  end
197
203
 
198
- # Delete one or more Items from a StatelyDB Store at the given key_paths.
204
+ # Delete up to 50 Items from a StatelyDB Store at the given key_paths.
199
205
  #
200
- # @param key_paths [String, Array<String>] the paths to the items
206
+ # @param key_paths [String, Array<String>] the paths to the items. Max 50 key paths.
201
207
  # @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
202
208
  # @raise [StatelyDB::Error::NotFound] if the item is not found
203
209
  # @return [void] nil
@@ -247,6 +253,25 @@ module StatelyDB
247
253
  raise
248
254
  end
249
255
 
256
+ # Construct the API endpoint from the region and endpoint.
257
+ # If the endpoint is provided, it will be returned as-is.
258
+ # If the region is provided and the endpoint is not,
259
+ # then the region-specific endpoint will be returned.
260
+ # If neither the region nor the endpoint is provided,
261
+ # then the default endpoint will be returned.
262
+ #
263
+ # @param endpoint [String] the endpoint to connect to
264
+ # @param region [Region] the region to connect to
265
+ # @return [String] the constructed endpoint
266
+ def self.make_endpoint(endpoint: nil, region: nil)
267
+ return endpoint unless endpoint.nil?
268
+ return "https://api.stately.cloud" if region.nil?
269
+
270
+ region = region.sub("aws-", "") if region.start_with?("aws-")
271
+
272
+ "https://#{region}.aws.api.stately.cloud"
273
+ end
274
+
250
275
  private
251
276
 
252
277
  # Process a list response from begin_list or continue_list
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. Consumers should not need to construct this
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
@@ -189,10 +189,12 @@ module StatelyDB
189
189
  resp.first
190
190
  end
191
191
 
192
- # Fetch a batch of Items from a StatelyDB Store at the given key_paths. Note that Items need to exist before being retrieved
193
- # inside a transaction.
192
+ # Fetch a batch of up to 100 Items from a StatelyDB Store at the given
193
+ # key_paths. Note that Items need to exist before being retrieved inside a
194
+ # transaction.
194
195
  #
195
- # @param key_paths [String, Array<String>] the paths to the items
196
+ # @param key_paths [String, Array<String>] the paths to the items. Max 100
197
+ # key paths.
196
198
  # @return [Array<StatelyDB::Item>] the items
197
199
  # @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
198
200
  # @raise [StatelyDB::Error::NotFound] if the item is not found
@@ -234,11 +236,11 @@ module StatelyDB
234
236
  resp.first
235
237
  end
236
238
 
237
- # Put a batch of Items into a StatelyDB Store. Results are not returned until the transaction is
239
+ # Put a batch of up to 50 Items into a StatelyDB Store. Results are not returned until the transaction is
238
240
  # committed and will be available in the Result object returned by commit. A list of identifiers
239
241
  # for the items will be returned while inside the transaction block.
240
242
  #
241
- # @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store
243
+ # @param items [StatelyDB::Item, Array<StatelyDB::Item>] the items to store. Max 50 items.
242
244
  # @return [Array<StatelyDB::UUID, String, Integer, nil>] the ids of the items
243
245
  #
244
246
  # @example
@@ -274,10 +276,10 @@ module StatelyDB
274
276
  end
275
277
  end
276
278
 
277
- # Delete one or more Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
279
+ # Delete up to 50 Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
278
280
  # committed and will be available in the Result object returned by commit.
279
281
  #
280
- # @param key_paths [String, Array<String>] the paths to the items
282
+ # @param key_paths [String, Array<String>] the paths to the items. Max 50 key paths.
281
283
  # @return [void] nil
282
284
  #
283
285
  # 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.2.0
4
+ version: 0.3.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-09-17 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -58,6 +58,7 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - README.md
61
62
  - lib/api/db/continue_list_pb.rb
62
63
  - lib/api/db/delete_pb.rb
63
64
  - lib/api/db/get_pb.rb