statelydb 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/common/net/conn.rb +16 -1
- data/lib/error.rb +20 -9
- data/lib/key_path.rb +2 -4
- 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: 712caae72447e18fda3456a1b70a9d1c6067994c9d084e715b6b0c0b92bd583f
|
4
|
+
data.tar.gz: 993afea8590f64f6a06c414508052aa42291654a1379e44da31b4da686d38f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f02e87c5fa5bf878b8a4421d3950a9a967dc3239f43f015ee670b1fb44ece8361f9a7314d224bd1f13ab258e002187d9aa5a6e69477781064d6c7493c33e2687
|
7
|
+
data.tar.gz: 270c30a9b29b264faf23ba1b842993bcb1a5d271b8cebcc6055980c8d311e180b92b617ca26fc29d0223b0c60f7a9b522df9dad1db03b591b6f9208c5aa757b5
|
data/lib/common/net/conn.rb
CHANGED
@@ -19,7 +19,22 @@ module StatelyDB
|
|
19
19
|
else
|
20
20
|
creds.compose(call_creds)
|
21
21
|
end
|
22
|
-
GRPC::Core::Channel.new(endpoint_uri.authority, {
|
22
|
+
GRPC::Core::Channel.new(endpoint_uri.authority, {
|
23
|
+
# This map contains grpc channel settings.
|
24
|
+
# Find the full list of supported keys
|
25
|
+
# here: https://grpc.github.io/grpc/core/group__grpc__arg__keys.html
|
26
|
+
|
27
|
+
# 2x the default of 8kb = 16kb
|
28
|
+
# Set max and absolute max to the same value
|
29
|
+
# to stop the grpc lib changing the error code to ResourceExhausted
|
30
|
+
# while still successfully reading the metadata because only the soft
|
31
|
+
# limit was exceeded.
|
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
|
37
|
+
}, creds)
|
23
38
|
end
|
24
39
|
end
|
25
40
|
end
|
data/lib/error.rb
CHANGED
@@ -22,14 +22,7 @@ module StatelyDB
|
|
22
22
|
# @param [String] stately_code
|
23
23
|
# @param [Exception] cause
|
24
24
|
def initialize(message, code: nil, stately_code: nil, cause: nil)
|
25
|
-
|
26
|
-
code_str = if code > 0
|
27
|
-
GRPC::Core::StatusCodes.constants.find do |c|
|
28
|
-
GRPC::Core::StatusCodes.const_get(c) === code
|
29
|
-
end.to_s.split("_").collect(&:capitalize).join
|
30
|
-
else
|
31
|
-
"Unknown"
|
32
|
-
end
|
25
|
+
code_str = self.class.grpc_code_to_string(code)
|
33
26
|
|
34
27
|
super("(#{code_str}/#{stately_code}): #{message}")
|
35
28
|
@code = code
|
@@ -50,13 +43,31 @@ module StatelyDB
|
|
50
43
|
raw_detail = status.details[0]
|
51
44
|
if raw_detail.type_url == "type.googleapis.com/stately.errors.StatelyErrorDetails"
|
52
45
|
error_details = Stately::Errors::StatelyErrorDetails.decode(raw_detail.value)
|
46
|
+
upstream_cause = error_details.upstream_cause.empty? ? nil : StandardError.new(error_details.upstream_cause) # rubocop:disable Metrics/BlockNesting
|
53
47
|
return new(error_details.message, code: error.code, stately_code: error_details.stately_code,
|
54
|
-
cause:
|
48
|
+
cause: upstream_cause)
|
55
49
|
end
|
56
50
|
end
|
57
51
|
end
|
58
52
|
|
59
53
|
new(error.message, code: GRPC::Core::StatusCodes::UNKNOWN, stately_code: "Unknown", cause: error)
|
60
54
|
end
|
55
|
+
|
56
|
+
def code_string
|
57
|
+
self.class.grpc_code_to_string(@code)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Turn a gRPC status code into a human-readable string. e.g. 3 -> "InvalidArgument"
|
61
|
+
# @param [Integer] code
|
62
|
+
# @return [String]
|
63
|
+
def self.grpc_code_to_string(code)
|
64
|
+
if code > 0
|
65
|
+
GRPC::Core::StatusCodes.constants.find do |c|
|
66
|
+
GRPC::Core::StatusCodes.const_get(c) === code
|
67
|
+
end.to_s.split("_").collect(&:capitalize).join
|
68
|
+
else
|
69
|
+
"Unknown"
|
70
|
+
end
|
71
|
+
end
|
61
72
|
end
|
62
73
|
end
|
data/lib/key_path.rb
CHANGED
@@ -48,16 +48,14 @@ module StatelyDB
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# If the value is a binary string, encode it as a url-safe base64 string with padding removed.
|
51
|
-
# Note that we also prepend the value with the ~ sigil to indicate that it is a base64 string.
|
52
51
|
#
|
53
52
|
# @param [String, StatelyDB::UUID, #to_s] value The value to convert to a key id.
|
54
53
|
# @return [String]
|
55
54
|
def self.to_key_id(value)
|
56
55
|
if value.is_a?(StatelyDB::UUID)
|
57
|
-
|
56
|
+
value.to_base64
|
58
57
|
elsif value.is_a?(String) && value.encoding == Encoding::BINARY
|
59
|
-
|
60
|
-
"~#{b64_value}"
|
58
|
+
[value].pack("m0").tr("=", "").tr("+/", "-_")
|
61
59
|
else
|
62
60
|
# Any other value is just converted to a string
|
63
61
|
value.to_s
|
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.2.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-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|