volcano-sdk 0.32.2 → 0.32.4

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: ea2aa2e1bb816dd0f4feef5c80d3dab616b24d56b54e81394fb63d5774bddae0
4
- data.tar.gz: 7ce5d0819d1a808fb4ee54c63c830a2a5173b0d15449174a007ac4b03236f0ac
3
+ metadata.gz: 5ef8f141d5ef4704ebc727b5836e416fb382af153ad9eb7748ef9d77181c947f
4
+ data.tar.gz: 271d7a8647274d6229de1f89fae7521486bc8617c9f4caa9b37d69b859fc9e7f
5
5
  SHA512:
6
- metadata.gz: '037199a369e46cb09775fb9e85b1396ff373d3a39b88411670ccae2b9a3494985755016b1af78f41d84cbe674ff5703c3f1cef4c49b7c8f05a3e9e7ba46b38ed'
7
- data.tar.gz: d178936e2018bcad91947371b2ee56878ef5f06f42df97e5a273035ae9395a2219062efd80bad18c2d8b4f13abd5eb8eb4908d17d8e46561faa1f4a36ac77471
6
+ metadata.gz: 51b1d9f99ed3b506ae5716c89c29e558d5a7b3cd8b1d324a00c7adc05dc9d4c23753797c0d1d317d0f059a91574e461af32c15b9a37eefe4f43d9820db594b21
7
+ data.tar.gz: 60a608b1b29a3599abdcbc815c37a6f49073921eabdec82926f7f6c51024a1b3ca2f803d72b7c4256722955d5db9e7cc2d3dcba22b6005581bc7581019f54201
@@ -29,10 +29,11 @@ module Volcano
29
29
  # DNS-safe name pattern an invoke checks would reject half the input.
30
30
  function_id = identifier(function_name, 'function_name')
31
31
  name = execution_name.nil? ? nil : execution_name_argument(execution_name)
32
+ request_payload = ImmutableRequestValue.capture(payload)
32
33
  response = Transport.invoke do
33
34
  @transport.start_durable_execution_from_application(
34
35
  authorization: @client.function_token,
35
- function_id: function_id, payload: payload.dup, execution_name: name
36
+ function_id: function_id, payload: request_payload, execution_name: name
36
37
  )
37
38
  end
38
39
  durable_execution(Transport.body(response, 202))
@@ -62,6 +63,7 @@ module Volcano
62
63
  project = identifier(project_id, 'project_id')
63
64
  function_id = identifier(function_name, 'function_name')
64
65
  validate_paging(page, limit)
66
+ status = status&.dup&.freeze
65
67
  response = Transport.invoke do
66
68
  @transport.list_durable_executions(
67
69
  authorization: @client.session_token, project_id: project, function_id: function_id,
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'time'
4
+ require_relative 'immutable_request_value'
4
5
 
5
6
  module Volcano
6
7
  DURABLE_EXECUTION_ATTRIBUTES = %i[
@@ -65,16 +66,10 @@ module Volcano
65
66
  # `result` is the function's own JSON, so it is frozen all the way down.
66
67
  def immutable_value(value)
67
68
  case value
68
- when Hash then immutable_value_hash(value)
69
- when Array then value.map { |item| immutable_value(item) }.freeze
70
- when Time, String then value.dup.freeze
69
+ when Hash, Array, Time, String then ImmutableRequestValue.capture(value)
71
70
  else value
72
71
  end
73
72
  end
74
-
75
- def immutable_value_hash(value)
76
- value.to_h { |key, item| [immutable_value(key), immutable_value(item)] }.freeze
77
- end
78
73
  end
79
74
 
80
75
  # One page of a durable function's executions, most recent first.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  module Volcano
4
6
  # Validates object metadata and paginated storage responses.
5
7
  module StorageObjectResponse
@@ -69,20 +71,40 @@ module Volcano
69
71
  def storage_json_hash(value)
70
72
  raise Error::TransportError, 'invalid storage JSON object' unless value.is_a?(Hash)
71
73
 
74
+ # @type var active: Hash[Integer, bool]
75
+ active = {}
76
+ copy = storage_json_container(value, active) { storage_json_entries(value, active) }
77
+ JSON.generate(copy)
78
+ copy
79
+ rescue JSON::GeneratorError
80
+ raise Error::TransportError, 'invalid storage JSON value', cause: nil
81
+ end
82
+
83
+ def storage_json_entries(value, active)
72
84
  value.to_h do |key, item|
73
85
  raise Error::TransportError, 'invalid storage JSON key' unless key.is_a?(String)
74
86
 
75
- [key, storage_json_value(item)]
87
+ [key, storage_json_value(item, active)]
76
88
  end
77
89
  end
78
90
 
79
- def storage_json_value(value)
91
+ def storage_json_value(value, active)
80
92
  case value
81
93
  when NilClass, TrueClass, FalseClass, Integer, Float, String then value
82
- when Array then value.map { |item| storage_json_value(item) }
83
- when Hash then storage_json_hash(value)
94
+ when Array then storage_json_container(value, active) { value.map { |item| storage_json_value(item, active) } }
95
+ when Hash then storage_json_container(value, active) { storage_json_entries(value, active) }
84
96
  else raise Error::TransportError, 'invalid storage JSON value'
85
97
  end
86
98
  end
99
+
100
+ def storage_json_container(value, active)
101
+ id = value.object_id
102
+ raise Error::TransportError, 'invalid storage JSON value' if active.key?(id) || active.size >= 100
103
+
104
+ active[id] = true
105
+ copy = yield
106
+ active.delete(id)
107
+ copy
108
+ end
87
109
  end
88
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Volcano
4
- VERSION = '0.32.2'
4
+ VERSION = '0.32.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volcano-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.2
4
+ version: 0.32.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kong