hatchet-sdk 0.5.0 → 0.7.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/CHANGELOG.md +14 -0
- data/lib/hatchet/batch.rb +58 -0
- data/lib/hatchet/clients/grpc/dispatcher.rb +42 -0
- data/lib/hatchet/clients/rest/.openapi-generator/FILES +9 -0
- data/lib/hatchet/clients/rest/README.md +16 -3
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/filter_api.rb +4 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/operator_api.rb +405 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/webhook_api.rb +2 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/api/worker_api.rb +3 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/api_meta.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/create_tenant_invite_request.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request.rb +105 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request_pause.rb +343 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/pause_workflow_request_unpause.rb +262 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_invite.rb +11 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member.rb +11 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_member_role.rb +2 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_invite_request.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/update_tenant_member_request.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_create_http_operator_request.rb +346 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_event.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_http_operator.rb +372 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_http_operator_list.rb +231 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_type.rb +3 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_summary.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_update_http_operator_request.rb +252 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_workflow_run.rb +14 -4
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow.rb +43 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_pause_scheduled_cron_run_queue_behavior.rb +40 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/workflow_update_request.rb +7 -8
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest.rb +9 -0
- data/lib/hatchet/concurrency.rb +5 -1
- data/lib/hatchet/context.rb +42 -3
- data/lib/hatchet/contracts/dispatcher/dispatcher_pb.rb +4 -1
- data/lib/hatchet/contracts/dispatcher/dispatcher_services_pb.rb +3 -0
- data/lib/hatchet/contracts/v1/workflows_pb.rb +2 -1
- data/lib/hatchet/durable_context.rb +5 -12
- data/lib/hatchet/features/cel.rb +2 -2
- data/lib/hatchet/features/cron.rb +5 -5
- data/lib/hatchet/features/events.rb +7 -7
- data/lib/hatchet/features/filters.rb +7 -7
- data/lib/hatchet/features/logs.rb +2 -2
- data/lib/hatchet/features/metrics.rb +6 -6
- data/lib/hatchet/features/rate_limits.rb +2 -2
- data/lib/hatchet/features/runs.rb +4 -5
- data/lib/hatchet/features/scheduled.rb +7 -7
- data/lib/hatchet/features/tenant.rb +2 -2
- data/lib/hatchet/features/workers.rb +5 -5
- data/lib/hatchet/features/workflows.rb +6 -6
- data/lib/hatchet/task.rb +13 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet/worker/runner.rb +113 -0
- data/lib/hatchet/workflow.rb +77 -33
- data/lib/hatchet-sdk.rb +86 -28
- data/sig/hatchet/batch.rbs +12 -0
- data/sig/hatchet/task.rbs +2 -0
- metadata +13 -2
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Hatchet API
|
|
3
|
+
|
|
4
|
+
#The Hatchet API
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module HatchetSdkRest
|
|
17
|
+
# Fields to update on an HTTP operator. Omitted fields are left unchanged.
|
|
18
|
+
class V1UpdateHTTPOperatorRequest
|
|
19
|
+
# The HTTPS endpoint (https, port 443) that assigned tasks are delivered to.
|
|
20
|
+
attr_accessor :trigger_endpoint
|
|
21
|
+
|
|
22
|
+
# An optional HTTPS endpoint polled to verify the operator endpoint is reachable.
|
|
23
|
+
attr_accessor :healthcheck_endpoint
|
|
24
|
+
|
|
25
|
+
# The secret used to HMAC-sign delivered requests. Write-only: it is never returned in responses. Provide a new value to rotate it.
|
|
26
|
+
attr_accessor :signing_secret
|
|
27
|
+
|
|
28
|
+
# Optional override for the per-request timeout backstop, in seconds.
|
|
29
|
+
attr_accessor :request_timeout_seconds
|
|
30
|
+
|
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
32
|
+
def self.attribute_map
|
|
33
|
+
{
|
|
34
|
+
:'trigger_endpoint' => :'triggerEndpoint',
|
|
35
|
+
:'healthcheck_endpoint' => :'healthcheckEndpoint',
|
|
36
|
+
:'signing_secret' => :'signingSecret',
|
|
37
|
+
:'request_timeout_seconds' => :'requestTimeoutSeconds'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns attribute mapping this model knows about
|
|
42
|
+
def self.acceptable_attribute_map
|
|
43
|
+
attribute_map
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Returns all the JSON keys this model knows about
|
|
47
|
+
def self.acceptable_attributes
|
|
48
|
+
acceptable_attribute_map.values
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Attribute type mapping.
|
|
52
|
+
def self.openapi_types
|
|
53
|
+
{
|
|
54
|
+
:'trigger_endpoint' => :'String',
|
|
55
|
+
:'healthcheck_endpoint' => :'String',
|
|
56
|
+
:'signing_secret' => :'String',
|
|
57
|
+
:'request_timeout_seconds' => :'Integer'
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# List of attributes with nullable: true
|
|
62
|
+
def self.openapi_nullable
|
|
63
|
+
Set.new([
|
|
64
|
+
])
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Initializes the object
|
|
68
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
69
|
+
def initialize(attributes = {})
|
|
70
|
+
if (!attributes.is_a?(Hash))
|
|
71
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::V1UpdateHTTPOperatorRequest` initialize method"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
75
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
76
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
77
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
78
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::V1UpdateHTTPOperatorRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
79
|
+
end
|
|
80
|
+
h[k.to_sym] = v
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if attributes.key?(:'trigger_endpoint')
|
|
84
|
+
self.trigger_endpoint = attributes[:'trigger_endpoint']
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
if attributes.key?(:'healthcheck_endpoint')
|
|
88
|
+
self.healthcheck_endpoint = attributes[:'healthcheck_endpoint']
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
if attributes.key?(:'signing_secret')
|
|
92
|
+
self.signing_secret = attributes[:'signing_secret']
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
if attributes.key?(:'request_timeout_seconds')
|
|
96
|
+
self.request_timeout_seconds = attributes[:'request_timeout_seconds']
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
101
|
+
# @return Array for valid properties with the reasons
|
|
102
|
+
def list_invalid_properties
|
|
103
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
104
|
+
invalid_properties = Array.new
|
|
105
|
+
invalid_properties
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Check to see if the all the properties in the model are valid
|
|
109
|
+
# @return true if the model is valid
|
|
110
|
+
def valid?
|
|
111
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
112
|
+
true
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Checks equality by comparing each attribute.
|
|
116
|
+
# @param [Object] Object to be compared
|
|
117
|
+
def ==(o)
|
|
118
|
+
return true if self.equal?(o)
|
|
119
|
+
self.class == o.class &&
|
|
120
|
+
trigger_endpoint == o.trigger_endpoint &&
|
|
121
|
+
healthcheck_endpoint == o.healthcheck_endpoint &&
|
|
122
|
+
signing_secret == o.signing_secret &&
|
|
123
|
+
request_timeout_seconds == o.request_timeout_seconds
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @see the `==` method
|
|
127
|
+
# @param [Object] Object to be compared
|
|
128
|
+
def eql?(o)
|
|
129
|
+
self == o
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Calculates hash code according to all attributes.
|
|
133
|
+
# @return [Integer] Hash code
|
|
134
|
+
def hash
|
|
135
|
+
[trigger_endpoint, healthcheck_endpoint, signing_secret, request_timeout_seconds].hash
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Builds the object from hash
|
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
140
|
+
# @return [Object] Returns the model itself
|
|
141
|
+
def self.build_from_hash(attributes)
|
|
142
|
+
return nil unless attributes.is_a?(Hash)
|
|
143
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
144
|
+
transformed_hash = {}
|
|
145
|
+
openapi_types.each_pair do |key, type|
|
|
146
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
147
|
+
transformed_hash["#{key}"] = nil
|
|
148
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
149
|
+
# check to ensure the input is an array given that the attribute
|
|
150
|
+
# is documented as an array but the input is not
|
|
151
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
152
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
153
|
+
end
|
|
154
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
155
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
new(transformed_hash)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Deserializes the data based on type
|
|
162
|
+
# @param string type Data type
|
|
163
|
+
# @param string value Value to be deserialized
|
|
164
|
+
# @return [Object] Deserialized data
|
|
165
|
+
def self._deserialize(type, value)
|
|
166
|
+
case type.to_sym
|
|
167
|
+
when :Time
|
|
168
|
+
Time.parse(value)
|
|
169
|
+
when :Date
|
|
170
|
+
Date.parse(value)
|
|
171
|
+
when :String
|
|
172
|
+
value.to_s
|
|
173
|
+
when :Integer
|
|
174
|
+
value.to_i
|
|
175
|
+
when :Float
|
|
176
|
+
value.to_f
|
|
177
|
+
when :Boolean
|
|
178
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
179
|
+
true
|
|
180
|
+
else
|
|
181
|
+
false
|
|
182
|
+
end
|
|
183
|
+
when :Object
|
|
184
|
+
# generic object (usually a Hash), return directly
|
|
185
|
+
value
|
|
186
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
187
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
188
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
189
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
190
|
+
k_type = Regexp.last_match[:k_type]
|
|
191
|
+
v_type = Regexp.last_match[:v_type]
|
|
192
|
+
{}.tap do |hash|
|
|
193
|
+
value.each do |k, v|
|
|
194
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
else # model
|
|
198
|
+
# models (e.g. Pet) or oneOf
|
|
199
|
+
klass = HatchetSdkRest.const_get(type)
|
|
200
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Returns the string representation of the object
|
|
205
|
+
# @return [String] String presentation of the object
|
|
206
|
+
def to_s
|
|
207
|
+
to_hash.to_s
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
211
|
+
# @return [Hash] Returns the object in the form of hash
|
|
212
|
+
def to_body
|
|
213
|
+
to_hash
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Returns the object in the form of hash
|
|
217
|
+
# @return [Hash] Returns the object in the form of hash
|
|
218
|
+
def to_hash
|
|
219
|
+
hash = {}
|
|
220
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
221
|
+
value = self.send(attr)
|
|
222
|
+
if value.nil?
|
|
223
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
224
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
hash[param] = _to_hash(value)
|
|
228
|
+
end
|
|
229
|
+
hash
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Outputs non-array value in the form of hash
|
|
233
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
234
|
+
# @param [Object] value Any valid value
|
|
235
|
+
# @return [Hash] Returns the value in the form of hash
|
|
236
|
+
def _to_hash(value)
|
|
237
|
+
if value.is_a?(Array)
|
|
238
|
+
value.compact.map { |v| _to_hash(v) }
|
|
239
|
+
elsif value.is_a?(Hash)
|
|
240
|
+
{}.tap do |hash|
|
|
241
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
242
|
+
end
|
|
243
|
+
elsif value.respond_to? :to_hash
|
|
244
|
+
value.to_hash
|
|
245
|
+
else
|
|
246
|
+
value
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
end
|
|
@@ -56,6 +56,9 @@ module HatchetSdkRest
|
|
|
56
56
|
|
|
57
57
|
attr_accessor :parent_task_external_id
|
|
58
58
|
|
|
59
|
+
# True when input, output, and event payload fields were omitted because the caller cannot view payloads. Additional metadata is still included.
|
|
60
|
+
attr_accessor :payloads_restricted
|
|
61
|
+
|
|
59
62
|
class EnumAttributeValidator
|
|
60
63
|
attr_reader :datatype
|
|
61
64
|
attr_reader :allowable_values
|
|
@@ -95,7 +98,8 @@ module HatchetSdkRest
|
|
|
95
98
|
:'error_message' => :'errorMessage',
|
|
96
99
|
:'workflow_version_id' => :'workflowVersionId',
|
|
97
100
|
:'created_at' => :'createdAt',
|
|
98
|
-
:'parent_task_external_id' => :'parentTaskExternalId'
|
|
101
|
+
:'parent_task_external_id' => :'parentTaskExternalId',
|
|
102
|
+
:'payloads_restricted' => :'payloadsRestricted'
|
|
99
103
|
}
|
|
100
104
|
end
|
|
101
105
|
|
|
@@ -126,7 +130,8 @@ module HatchetSdkRest
|
|
|
126
130
|
:'error_message' => :'String',
|
|
127
131
|
:'workflow_version_id' => :'String',
|
|
128
132
|
:'created_at' => :'Time',
|
|
129
|
-
:'parent_task_external_id' => :'String'
|
|
133
|
+
:'parent_task_external_id' => :'String',
|
|
134
|
+
:'payloads_restricted' => :'Boolean'
|
|
130
135
|
}
|
|
131
136
|
end
|
|
132
137
|
|
|
@@ -225,6 +230,10 @@ module HatchetSdkRest
|
|
|
225
230
|
if attributes.key?(:'parent_task_external_id')
|
|
226
231
|
self.parent_task_external_id = attributes[:'parent_task_external_id']
|
|
227
232
|
end
|
|
233
|
+
|
|
234
|
+
if attributes.key?(:'payloads_restricted')
|
|
235
|
+
self.payloads_restricted = attributes[:'payloads_restricted']
|
|
236
|
+
end
|
|
228
237
|
end
|
|
229
238
|
|
|
230
239
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -412,7 +421,8 @@ module HatchetSdkRest
|
|
|
412
421
|
error_message == o.error_message &&
|
|
413
422
|
workflow_version_id == o.workflow_version_id &&
|
|
414
423
|
created_at == o.created_at &&
|
|
415
|
-
parent_task_external_id == o.parent_task_external_id
|
|
424
|
+
parent_task_external_id == o.parent_task_external_id &&
|
|
425
|
+
payloads_restricted == o.payloads_restricted
|
|
416
426
|
end
|
|
417
427
|
|
|
418
428
|
# @see the `==` method
|
|
@@ -424,7 +434,7 @@ module HatchetSdkRest
|
|
|
424
434
|
# Calculates hash code according to all attributes.
|
|
425
435
|
# @return [Integer] Hash code
|
|
426
436
|
def hash
|
|
427
|
-
[metadata, status, tenant_id, display_name, workflow_id, output, input, started_at, finished_at, duration, additional_metadata, error_message, workflow_version_id, created_at, parent_task_external_id].hash
|
|
437
|
+
[metadata, status, tenant_id, display_name, workflow_id, output, input, started_at, finished_at, duration, additional_metadata, error_message, workflow_version_id, created_at, parent_task_external_id, payloads_restricted].hash
|
|
428
438
|
end
|
|
429
439
|
|
|
430
440
|
# Builds the object from hash
|
|
@@ -29,6 +29,12 @@ module HatchetSdkRest
|
|
|
29
29
|
# Whether the workflow is paused.
|
|
30
30
|
attr_accessor :is_paused
|
|
31
31
|
|
|
32
|
+
# The behavior of cron runs triggered while the workflow is paused.
|
|
33
|
+
attr_accessor :paused_workflow_cron_run_queue_behavior
|
|
34
|
+
|
|
35
|
+
# The behavior of scheduled runs triggered while the workflow is paused.
|
|
36
|
+
attr_accessor :paused_workflow_scheduled_run_queue_behavior
|
|
37
|
+
|
|
32
38
|
attr_accessor :versions
|
|
33
39
|
|
|
34
40
|
# The tags of the workflow.
|
|
@@ -37,6 +43,28 @@ module HatchetSdkRest
|
|
|
37
43
|
# The jobs of the workflow.
|
|
38
44
|
attr_accessor :jobs
|
|
39
45
|
|
|
46
|
+
class EnumAttributeValidator
|
|
47
|
+
attr_reader :datatype
|
|
48
|
+
attr_reader :allowable_values
|
|
49
|
+
|
|
50
|
+
def initialize(datatype, allowable_values)
|
|
51
|
+
@allowable_values = allowable_values.map do |value|
|
|
52
|
+
case datatype.to_s
|
|
53
|
+
when /Integer/i
|
|
54
|
+
value.to_i
|
|
55
|
+
when /Float/i
|
|
56
|
+
value.to_f
|
|
57
|
+
else
|
|
58
|
+
value
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def valid?(value)
|
|
64
|
+
!value || allowable_values.include?(value)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
40
68
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
41
69
|
def self.attribute_map
|
|
42
70
|
{
|
|
@@ -45,6 +73,8 @@ module HatchetSdkRest
|
|
|
45
73
|
:'tenant_id' => :'tenantId',
|
|
46
74
|
:'description' => :'description',
|
|
47
75
|
:'is_paused' => :'isPaused',
|
|
76
|
+
:'paused_workflow_cron_run_queue_behavior' => :'pausedWorkflowCronRunQueueBehavior',
|
|
77
|
+
:'paused_workflow_scheduled_run_queue_behavior' => :'pausedWorkflowScheduledRunQueueBehavior',
|
|
48
78
|
:'versions' => :'versions',
|
|
49
79
|
:'tags' => :'tags',
|
|
50
80
|
:'jobs' => :'jobs'
|
|
@@ -69,6 +99,8 @@ module HatchetSdkRest
|
|
|
69
99
|
:'tenant_id' => :'String',
|
|
70
100
|
:'description' => :'String',
|
|
71
101
|
:'is_paused' => :'Boolean',
|
|
102
|
+
:'paused_workflow_cron_run_queue_behavior' => :'WorkflowPauseScheduledCronRunQueueBehavior',
|
|
103
|
+
:'paused_workflow_scheduled_run_queue_behavior' => :'WorkflowPauseScheduledCronRunQueueBehavior',
|
|
72
104
|
:'versions' => :'Array<WorkflowVersionMeta>',
|
|
73
105
|
:'tags' => :'Array<WorkflowTag>',
|
|
74
106
|
:'jobs' => :'Array<Job>'
|
|
@@ -123,6 +155,14 @@ module HatchetSdkRest
|
|
|
123
155
|
self.is_paused = attributes[:'is_paused']
|
|
124
156
|
end
|
|
125
157
|
|
|
158
|
+
if attributes.key?(:'paused_workflow_cron_run_queue_behavior')
|
|
159
|
+
self.paused_workflow_cron_run_queue_behavior = attributes[:'paused_workflow_cron_run_queue_behavior']
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if attributes.key?(:'paused_workflow_scheduled_run_queue_behavior')
|
|
163
|
+
self.paused_workflow_scheduled_run_queue_behavior = attributes[:'paused_workflow_scheduled_run_queue_behavior']
|
|
164
|
+
end
|
|
165
|
+
|
|
126
166
|
if attributes.key?(:'versions')
|
|
127
167
|
if (value = attributes[:'versions']).is_a?(Array)
|
|
128
168
|
self.versions = value
|
|
@@ -212,6 +252,8 @@ module HatchetSdkRest
|
|
|
212
252
|
tenant_id == o.tenant_id &&
|
|
213
253
|
description == o.description &&
|
|
214
254
|
is_paused == o.is_paused &&
|
|
255
|
+
paused_workflow_cron_run_queue_behavior == o.paused_workflow_cron_run_queue_behavior &&
|
|
256
|
+
paused_workflow_scheduled_run_queue_behavior == o.paused_workflow_scheduled_run_queue_behavior &&
|
|
215
257
|
versions == o.versions &&
|
|
216
258
|
tags == o.tags &&
|
|
217
259
|
jobs == o.jobs
|
|
@@ -226,7 +268,7 @@ module HatchetSdkRest
|
|
|
226
268
|
# Calculates hash code according to all attributes.
|
|
227
269
|
# @return [Integer] Hash code
|
|
228
270
|
def hash
|
|
229
|
-
[metadata, name, tenant_id, description, is_paused, versions, tags, jobs].hash
|
|
271
|
+
[metadata, name, tenant_id, description, is_paused, paused_workflow_cron_run_queue_behavior, paused_workflow_scheduled_run_queue_behavior, versions, tags, jobs].hash
|
|
230
272
|
end
|
|
231
273
|
|
|
232
274
|
# Builds the object from hash
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Hatchet API
|
|
3
|
+
|
|
4
|
+
#The Hatchet API
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module HatchetSdkRest
|
|
17
|
+
class WorkflowPauseScheduledCronRunQueueBehavior
|
|
18
|
+
DROP = "DROP".freeze
|
|
19
|
+
QUEUE = "QUEUE".freeze
|
|
20
|
+
|
|
21
|
+
def self.all_vars
|
|
22
|
+
@all_vars ||= [DROP, QUEUE].freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Builds the enum from string
|
|
26
|
+
# @param [String] The enum value in the form of the string
|
|
27
|
+
# @return [String] The enum value
|
|
28
|
+
def self.build_from_hash(value)
|
|
29
|
+
new.build_from_hash(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the enum from string
|
|
33
|
+
# @param [String] The enum value in the form of the string
|
|
34
|
+
# @return [String] The enum value
|
|
35
|
+
def build_from_hash(value)
|
|
36
|
+
return value if WorkflowPauseScheduledCronRunQueueBehavior.all_vars.include?(value)
|
|
37
|
+
raise "Invalid ENUM value #{value} for class #WorkflowPauseScheduledCronRunQueueBehavior"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -15,13 +15,12 @@ require 'time'
|
|
|
15
15
|
|
|
16
16
|
module HatchetSdkRest
|
|
17
17
|
class WorkflowUpdateRequest
|
|
18
|
-
|
|
19
|
-
attr_accessor :is_paused
|
|
18
|
+
attr_accessor :pause
|
|
20
19
|
|
|
21
20
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
22
21
|
def self.attribute_map
|
|
23
22
|
{
|
|
24
|
-
:'
|
|
23
|
+
:'pause' => :'pause'
|
|
25
24
|
}
|
|
26
25
|
end
|
|
27
26
|
|
|
@@ -38,7 +37,7 @@ module HatchetSdkRest
|
|
|
38
37
|
# Attribute type mapping.
|
|
39
38
|
def self.openapi_types
|
|
40
39
|
{
|
|
41
|
-
:'
|
|
40
|
+
:'pause' => :'PauseWorkflowRequest'
|
|
42
41
|
}
|
|
43
42
|
end
|
|
44
43
|
|
|
@@ -64,8 +63,8 @@ module HatchetSdkRest
|
|
|
64
63
|
h[k.to_sym] = v
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
if attributes.key?(:'
|
|
68
|
-
self.
|
|
66
|
+
if attributes.key?(:'pause')
|
|
67
|
+
self.pause = attributes[:'pause']
|
|
69
68
|
end
|
|
70
69
|
end
|
|
71
70
|
|
|
@@ -89,7 +88,7 @@ module HatchetSdkRest
|
|
|
89
88
|
def ==(o)
|
|
90
89
|
return true if self.equal?(o)
|
|
91
90
|
self.class == o.class &&
|
|
92
|
-
|
|
91
|
+
pause == o.pause
|
|
93
92
|
end
|
|
94
93
|
|
|
95
94
|
# @see the `==` method
|
|
@@ -101,7 +100,7 @@ module HatchetSdkRest
|
|
|
101
100
|
# Calculates hash code according to all attributes.
|
|
102
101
|
# @return [Integer] Hash code
|
|
103
102
|
def hash
|
|
104
|
-
[
|
|
103
|
+
[pause].hash
|
|
105
104
|
end
|
|
106
105
|
|
|
107
106
|
# Builds the object from hash
|
|
@@ -75,6 +75,9 @@ HatchetSdkRest.autoload :OtelSpanKind, 'hatchet-sdk-rest/models/otel_span_kind'
|
|
|
75
75
|
HatchetSdkRest.autoload :OtelSpanList, 'hatchet-sdk-rest/models/otel_span_list'
|
|
76
76
|
HatchetSdkRest.autoload :OtelStatusCode, 'hatchet-sdk-rest/models/otel_status_code'
|
|
77
77
|
HatchetSdkRest.autoload :PaginationResponse, 'hatchet-sdk-rest/models/pagination_response'
|
|
78
|
+
HatchetSdkRest.autoload :PauseWorkflowRequest, 'hatchet-sdk-rest/models/pause_workflow_request'
|
|
79
|
+
HatchetSdkRest.autoload :PauseWorkflowRequestPause, 'hatchet-sdk-rest/models/pause_workflow_request_pause'
|
|
80
|
+
HatchetSdkRest.autoload :PauseWorkflowRequestUnpause, 'hatchet-sdk-rest/models/pause_workflow_request_unpause'
|
|
78
81
|
HatchetSdkRest.autoload :PullRequest, 'hatchet-sdk-rest/models/pull_request'
|
|
79
82
|
HatchetSdkRest.autoload :PullRequestState, 'hatchet-sdk-rest/models/pull_request_state'
|
|
80
83
|
HatchetSdkRest.autoload :QueueMetrics, 'hatchet-sdk-rest/models/queue_metrics'
|
|
@@ -158,6 +161,7 @@ HatchetSdkRest.autoload :V1CELDebugResponseStatus, 'hatchet-sdk-rest/models/v1_c
|
|
|
158
161
|
HatchetSdkRest.autoload :V1CancelTaskRequest, 'hatchet-sdk-rest/models/v1_cancel_task_request'
|
|
159
162
|
HatchetSdkRest.autoload :V1CancelledTasks, 'hatchet-sdk-rest/models/v1_cancelled_tasks'
|
|
160
163
|
HatchetSdkRest.autoload :V1CreateFilterRequest, 'hatchet-sdk-rest/models/v1_create_filter_request'
|
|
164
|
+
HatchetSdkRest.autoload :V1CreateHTTPOperatorRequest, 'hatchet-sdk-rest/models/v1_create_http_operator_request'
|
|
161
165
|
HatchetSdkRest.autoload :V1CreateWebhookRequest, 'hatchet-sdk-rest/models/v1_create_webhook_request'
|
|
162
166
|
HatchetSdkRest.autoload :V1CreateWebhookRequestAPIKey, 'hatchet-sdk-rest/models/v1_create_webhook_request_api_key'
|
|
163
167
|
HatchetSdkRest.autoload :V1CreateWebhookRequestBase, 'hatchet-sdk-rest/models/v1_create_webhook_request_base'
|
|
@@ -174,6 +178,8 @@ HatchetSdkRest.autoload :V1EventTriggeredRun, 'hatchet-sdk-rest/models/v1_event_
|
|
|
174
178
|
HatchetSdkRest.autoload :V1EventWorkflowRunSummary, 'hatchet-sdk-rest/models/v1_event_workflow_run_summary'
|
|
175
179
|
HatchetSdkRest.autoload :V1Filter, 'hatchet-sdk-rest/models/v1_filter'
|
|
176
180
|
HatchetSdkRest.autoload :V1FilterList, 'hatchet-sdk-rest/models/v1_filter_list'
|
|
181
|
+
HatchetSdkRest.autoload :V1HTTPOperator, 'hatchet-sdk-rest/models/v1_http_operator'
|
|
182
|
+
HatchetSdkRest.autoload :V1HTTPOperatorList, 'hatchet-sdk-rest/models/v1_http_operator_list'
|
|
177
183
|
HatchetSdkRest.autoload :V1LogLine, 'hatchet-sdk-rest/models/v1_log_line'
|
|
178
184
|
HatchetSdkRest.autoload :V1LogLineLevel, 'hatchet-sdk-rest/models/v1_log_line_level'
|
|
179
185
|
HatchetSdkRest.autoload :V1LogLineList, 'hatchet-sdk-rest/models/v1_log_line_list'
|
|
@@ -200,6 +206,7 @@ HatchetSdkRest.autoload :V1TaskTiming, 'hatchet-sdk-rest/models/v1_task_timing'
|
|
|
200
206
|
HatchetSdkRest.autoload :V1TaskTimingList, 'hatchet-sdk-rest/models/v1_task_timing_list'
|
|
201
207
|
HatchetSdkRest.autoload :V1TriggerWorkflowRunRequest, 'hatchet-sdk-rest/models/v1_trigger_workflow_run_request'
|
|
202
208
|
HatchetSdkRest.autoload :V1UpdateFilterRequest, 'hatchet-sdk-rest/models/v1_update_filter_request'
|
|
209
|
+
HatchetSdkRest.autoload :V1UpdateHTTPOperatorRequest, 'hatchet-sdk-rest/models/v1_update_http_operator_request'
|
|
203
210
|
HatchetSdkRest.autoload :V1UpdateWebhookRequest, 'hatchet-sdk-rest/models/v1_update_webhook_request'
|
|
204
211
|
HatchetSdkRest.autoload :V1WaitItem, 'hatchet-sdk-rest/models/v1_wait_item'
|
|
205
212
|
HatchetSdkRest.autoload :V1Webhook, 'hatchet-sdk-rest/models/v1_webhook'
|
|
@@ -238,6 +245,7 @@ HatchetSdkRest.autoload :WorkflowConcurrency, 'hatchet-sdk-rest/models/workflow_
|
|
|
238
245
|
HatchetSdkRest.autoload :WorkflowKind, 'hatchet-sdk-rest/models/workflow_kind'
|
|
239
246
|
HatchetSdkRest.autoload :WorkflowList, 'hatchet-sdk-rest/models/workflow_list'
|
|
240
247
|
HatchetSdkRest.autoload :WorkflowMetrics, 'hatchet-sdk-rest/models/workflow_metrics'
|
|
248
|
+
HatchetSdkRest.autoload :WorkflowPauseScheduledCronRunQueueBehavior, 'hatchet-sdk-rest/models/workflow_pause_scheduled_cron_run_queue_behavior'
|
|
241
249
|
HatchetSdkRest.autoload :WorkflowRun, 'hatchet-sdk-rest/models/workflow_run'
|
|
242
250
|
HatchetSdkRest.autoload :WorkflowRunList, 'hatchet-sdk-rest/models/workflow_run_list'
|
|
243
251
|
HatchetSdkRest.autoload :WorkflowRunOrderByDirection, 'hatchet-sdk-rest/models/workflow_run_order_by_direction'
|
|
@@ -272,6 +280,7 @@ HatchetSdkRest.autoload :HealthcheckApi, 'hatchet-sdk-rest/api/healthcheck_api'
|
|
|
272
280
|
HatchetSdkRest.autoload :LogApi, 'hatchet-sdk-rest/api/log_api'
|
|
273
281
|
HatchetSdkRest.autoload :MetadataApi, 'hatchet-sdk-rest/api/metadata_api'
|
|
274
282
|
HatchetSdkRest.autoload :ObservabilityApi, 'hatchet-sdk-rest/api/observability_api'
|
|
283
|
+
HatchetSdkRest.autoload :OperatorApi, 'hatchet-sdk-rest/api/operator_api'
|
|
275
284
|
HatchetSdkRest.autoload :RateLimitsApi, 'hatchet-sdk-rest/api/rate_limits_api'
|
|
276
285
|
HatchetSdkRest.autoload :SNSApi, 'hatchet-sdk-rest/api/sns_api'
|
|
277
286
|
HatchetSdkRest.autoload :SlackApi, 'hatchet-sdk-rest/api/slack_api'
|
data/lib/hatchet/concurrency.rb
CHANGED
|
@@ -7,6 +7,8 @@ module Hatchet
|
|
|
7
7
|
CANCEL_NEWEST = :cancel_newest
|
|
8
8
|
GROUP_ROUND_ROBIN = :group_round_robin
|
|
9
9
|
QUEUE = :queue
|
|
10
|
+
CANCEL_QUEUED_EXCEPT_NEWEST = :cancel_queued_except_newest
|
|
11
|
+
CANCEL_QUEUED_EXCEPT_OLDEST = :cancel_queued_except_oldest
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
# Defines a concurrency expression for workflow or task-level concurrency control
|
|
@@ -30,7 +32,7 @@ module Hatchet
|
|
|
30
32
|
# @return [Integer] Maximum concurrent runs for this key
|
|
31
33
|
attr_reader :max_runs
|
|
32
34
|
|
|
33
|
-
# @return [Symbol] Strategy when limit is exceeded (:cancel_in_progress, :cancel_newest, :group_round_robin, :queue)
|
|
35
|
+
# @return [Symbol] Strategy when limit is exceeded (:cancel_in_progress, :cancel_newest, :group_round_robin, :queue, :cancel_queued_except_newest, :cancel_queued_except_oldest)
|
|
34
36
|
attr_reader :limit_strategy
|
|
35
37
|
|
|
36
38
|
# @param expression [String] CEL expression evaluated against input
|
|
@@ -59,6 +61,8 @@ module Hatchet
|
|
|
59
61
|
group_round_robin: :GROUP_ROUND_ROBIN,
|
|
60
62
|
queue: :QUEUE_NEWEST,
|
|
61
63
|
drop_newest: :DROP_NEWEST,
|
|
64
|
+
cancel_queued_except_newest: :CANCEL_QUEUED_EXCEPT_NEWEST,
|
|
65
|
+
cancel_queued_except_oldest: :CANCEL_QUEUED_EXCEPT_OLDEST,
|
|
62
66
|
}.freeze
|
|
63
67
|
|
|
64
68
|
# Convert to a V1::Concurrency protobuf message
|
data/lib/hatchet/context.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
3
5
|
module Hatchet
|
|
4
6
|
# Context object passed to task execution blocks.
|
|
5
7
|
#
|
|
@@ -128,10 +130,28 @@ module Hatchet
|
|
|
128
130
|
@client&.logger&.info(msg) || puts(msg)
|
|
129
131
|
end
|
|
130
132
|
|
|
131
|
-
# Cancel the current workflow run
|
|
133
|
+
# Cancel the current workflow run.
|
|
134
|
+
#
|
|
135
|
+
# Batch tasks share one context across every buffered member, so there is no single
|
|
136
|
+
# task run to cancel; instead this sends a batch CANCELLED event covering every
|
|
137
|
+
# member of the batch.
|
|
132
138
|
def cancel
|
|
133
139
|
@cancelled = true
|
|
134
140
|
@exit_flag = true
|
|
141
|
+
|
|
142
|
+
if batch_action?
|
|
143
|
+
begin
|
|
144
|
+
@dispatcher_client&.send_batch_action_event(
|
|
145
|
+
action: @action,
|
|
146
|
+
event_type: :STEP_EVENT_TYPE_CANCELLED,
|
|
147
|
+
items: batch_member_ids.map { |id| { task_run_external_id: id } },
|
|
148
|
+
)
|
|
149
|
+
rescue StandardError
|
|
150
|
+
nil
|
|
151
|
+
end
|
|
152
|
+
return
|
|
153
|
+
end
|
|
154
|
+
|
|
135
155
|
return unless @client && @workflow_run_id
|
|
136
156
|
|
|
137
157
|
begin
|
|
@@ -198,11 +218,30 @@ module Hatchet
|
|
|
198
218
|
task_run_errors.find { |e| e.respond_to?(:task_name) && e.task_name == key }
|
|
199
219
|
end
|
|
200
220
|
|
|
201
|
-
# Access the worker context for worker-level operations
|
|
221
|
+
# Access the worker context for worker-level operations. The returned
|
|
222
|
+
# {WorkerContext} exposes +id+ (the worker id), +labels+ (the current
|
|
223
|
+
# worker labels), and +upsert_labels+ to add or update worker labels on
|
|
224
|
+
# the server at runtime.
|
|
202
225
|
#
|
|
203
|
-
# @return [WorkerContext, nil]
|
|
226
|
+
# @return [WorkerContext, nil] The worker context, if one is attached
|
|
204
227
|
def worker
|
|
205
228
|
@worker_context
|
|
206
229
|
end
|
|
230
|
+
|
|
231
|
+
private
|
|
232
|
+
|
|
233
|
+
def batch_action?
|
|
234
|
+
@action.respond_to?(:action_type) && @action.action_type == :START_BATCH
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def batch_member_ids
|
|
238
|
+
raw = @action.respond_to?(:action_payload) ? @action.action_payload : nil
|
|
239
|
+
return [] if raw.nil? || raw.to_s.empty?
|
|
240
|
+
|
|
241
|
+
parsed = JSON.parse(raw)
|
|
242
|
+
parsed.is_a?(Hash) ? parsed.keys : []
|
|
243
|
+
rescue JSON::ParserError
|
|
244
|
+
[]
|
|
245
|
+
end
|
|
207
246
|
end
|
|
208
247
|
end
|