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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4c1af818c57771a88c10b8f489b0a073816dab122d462b54a0238cf593b7c11
4
- data.tar.gz: 388b5a8cb32e8f9e18f0dd6195b230877bf20d6c91adf959cbd1e2a04a40db3a
3
+ metadata.gz: 712caae72447e18fda3456a1b70a9d1c6067994c9d084e715b6b0c0b92bd583f
4
+ data.tar.gz: 993afea8590f64f6a06c414508052aa42291654a1379e44da31b4da686d38f84
5
5
  SHA512:
6
- metadata.gz: 766faff6f9a61e837b38d1e02f94adde711829efa68495952cf0ed934a16d61db2f4aa1cf371bbd8775ececea60baa45dd427a6497e2a729a7f5da43c7460085
7
- data.tar.gz: 8430e4a08b529353175e44a62677f8739deb85e9c934d414d0a87d6b29e0071d13446289efb20189d511bc33c0fed7e317ad455cc6027ee79a06a747f5865dcd
6
+ metadata.gz: f02e87c5fa5bf878b8a4421d3950a9a967dc3239f43f015ee670b1fb44ece8361f9a7314d224bd1f13ab258e002187d9aa5a6e69477781064d6c7493c33e2687
7
+ data.tar.gz: 270c30a9b29b264faf23ba1b842993bcb1a5d271b8cebcc6055980c8d311e180b92b617ca26fc29d0223b0c60f7a9b522df9dad1db03b591b6f9208c5aa757b5
@@ -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, {}, creds)
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
- # Turn a gRPC status code into a human-readable string. e.g. 3 -> "InvalidArgument"
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: error_details.upstream_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
- "~#{value.to_base64}"
56
+ value.to_base64
58
57
  elsif value.is_a?(String) && value.encoding == Encoding::BINARY
59
- b64_value = [value].pack("m0").tr("=", "").tr("+/", "-_")
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.1.2
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-05 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async