hatchet-sdk 0.12.2 → 0.12.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/hatchet/clients/grpc/admin.rb +2 -2
- data/lib/hatchet/clients/grpc/event_client.rb +2 -2
- data/lib/hatchet/clients/grpc/server_retry_delay.rb +63 -0
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/concurrency_limit_strategy.rb +4 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/feature_flag_id.rb +2 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/tenant_resource.rb +4 -1
- data/lib/hatchet/clients/rest/lib/hatchet-sdk-rest/models/v1_task_event_type.rb +2 -1
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet-sdk.rb +1 -0
- data/sig/hatchet/clients/grpc/server_retry_delay.rbs +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb6f313f116b6014c7dd189acf125a9b007982be663ada731d531976ca110882
|
|
4
|
+
data.tar.gz: c15815dff2aa4b86bcdb1e741b518d86d4c726edd835e6f22dfd099553801953
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 828340d3c9f6b48df569028ff8778a38a656774370f8c0c32ce5596f43ddfd159a5c11cc600095b057e4f6e4b996f640a9b3eb3edb2ce7698c70aff357757e1a
|
|
7
|
+
data.tar.gz: cb5480cf9131f5da3c4964c949aca9bbdfd4a9eab3b8a5e0e1ef7aff45c6f5c7fe085c9cc15f8a01f8d8126078f6a1727713dd15536c6e4c05676395634e7574
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to Hatchet's Ruby SDK will be documented in this changelog.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.12.4] - 2026-11-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Triggering a run, bulk triggering and pushing events, one at a time or in bulk, now retry when the engine throttles the call with `RESOURCE_EXHAUSTED` and a `google.rpc.RetryInfo` detail, waiting the delay the server asks for. Other errors, including `RESOURCE_EXHAUSTED` without `RetryInfo`, are raised at once as before. The wait doubles with each retry up to 5 seconds and is extended by a random amount of up to 20%, so that clients throttled together do not all retry at the same moment. At most 5 attempts are made, and a call the server asks to wait longer than 5 seconds fails at once with the server's error.
|
|
13
|
+
|
|
14
|
+
## [0.12.3] - 2026-11-16
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- The REST client accepts the `BATCH_BUFFERED` task event type and the `STREAM_TOPIC`, `STREAM_MESSAGE` and `STREAM_RETENTION` tenant resources, which the engine already returns.
|
|
19
|
+
|
|
8
20
|
## [0.12.2] - 2026-11-10
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -91,7 +91,7 @@ module Hatchet
|
|
|
91
91
|
request = ::V1::TriggerWorkflowRequest.new(**request_args)
|
|
92
92
|
|
|
93
93
|
begin
|
|
94
|
-
response = @v0_stub.trigger_workflow(request, metadata: @config.auth_metadata)
|
|
94
|
+
response = ServerRetryDelay.call { @v0_stub.trigger_workflow(request, metadata: @config.auth_metadata) }
|
|
95
95
|
response.workflow_run_id
|
|
96
96
|
rescue ::GRPC::AlreadyExists => e
|
|
97
97
|
run_id = extract_idempotency_run_id(e)
|
|
@@ -152,7 +152,7 @@ module Hatchet
|
|
|
152
152
|
begin
|
|
153
153
|
requests.each_slice(BULK_TRIGGER_BATCH_SIZE) do |batch|
|
|
154
154
|
bulk_request = ::BulkTriggerWorkflowRequest.new(workflows: batch)
|
|
155
|
-
response = @v0_stub.bulk_trigger_workflow(bulk_request, metadata: @config.auth_metadata)
|
|
155
|
+
response = ServerRetryDelay.call { @v0_stub.bulk_trigger_workflow(bulk_request, metadata: @config.auth_metadata) }
|
|
156
156
|
all_run_ids.concat(response.workflow_run_ids.to_a)
|
|
157
157
|
end
|
|
158
158
|
rescue ::GRPC::AlreadyExists => e
|
|
@@ -64,7 +64,7 @@ module Hatchet
|
|
|
64
64
|
request_args[:scope] = scope if scope
|
|
65
65
|
|
|
66
66
|
request = ::PushEventRequest.new(**request_args)
|
|
67
|
-
@stub.push(request, metadata: @config.auth_metadata)
|
|
67
|
+
ServerRetryDelay.call { @stub.push(request, metadata: @config.auth_metadata) }
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
# Push multiple events via gRPC.
|
|
@@ -103,7 +103,7 @@ module Hatchet
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
request = ::BulkPushEventRequest.new(events: items)
|
|
106
|
-
@stub.bulk_push(request, metadata: @config.auth_metadata)
|
|
106
|
+
ServerRetryDelay.call { @stub.bulk_push(request, metadata: @config.auth_metadata) }
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
# Put a log message for a task run.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "google/protobuf/well_known_types"
|
|
4
|
+
require "google/rpc/error_details_pb"
|
|
5
|
+
|
|
6
|
+
module Hatchet
|
|
7
|
+
module Clients
|
|
8
|
+
module Grpc
|
|
9
|
+
# Retries a call the engine throttled, waiting the delay the server asked for.
|
|
10
|
+
#
|
|
11
|
+
# A call is retried only when the server says how long to wait: RESOURCE_EXHAUSTED with a
|
|
12
|
+
# RetryInfo detail and a positive delay. Everything else is raised at once, including
|
|
13
|
+
# RESOURCE_EXHAUSTED without RetryInfo, which is either a quota that a retry will not clear or
|
|
14
|
+
# the per-API-token rate limit; neither carries a delay, so the SDK has no wait to honor.
|
|
15
|
+
#
|
|
16
|
+
# The delay is doubled for each retry already made, which is the client behavior RetryInfo
|
|
17
|
+
# documents: a server that keeps throttling repeats the same delay, so without the doubling
|
|
18
|
+
# the client would not back off.
|
|
19
|
+
module ServerRetryDelay
|
|
20
|
+
MAX_ATTEMPTS = 5
|
|
21
|
+
|
|
22
|
+
# The longest wait the SDK accepts from a server; the wait blocks the caller. A call the server
|
|
23
|
+
# asks to wait longer fails at once with the server's error, since every retry before that
|
|
24
|
+
# delay would be refused.
|
|
25
|
+
MAX_DELAY_SECONDS = 5.0
|
|
26
|
+
|
|
27
|
+
# The most a wait is extended, as a share of the wait. Clients throttled at the same moment
|
|
28
|
+
# get the same delay; the random extension keeps them from all coming back at the same
|
|
29
|
+
# moment. It only extends the wait, since a retry before the server's delay would be refused.
|
|
30
|
+
JITTER = 0.2
|
|
31
|
+
|
|
32
|
+
module_function
|
|
33
|
+
|
|
34
|
+
# @yield The gRPC call, run again for each retry
|
|
35
|
+
# @return [Object] The block's result
|
|
36
|
+
def call
|
|
37
|
+
attempt = 1
|
|
38
|
+
begin
|
|
39
|
+
yield
|
|
40
|
+
rescue ::GRPC::ResourceExhausted => e
|
|
41
|
+
delay = retry_delay(e)
|
|
42
|
+
raise unless delay&.positive? && delay <= MAX_DELAY_SECONDS && attempt < MAX_ATTEMPTS
|
|
43
|
+
|
|
44
|
+
wait = [delay * (2**(attempt - 1)), MAX_DELAY_SECONDS].min
|
|
45
|
+
sleep(wait * (1 + rand(0.0..JITTER)))
|
|
46
|
+
attempt += 1
|
|
47
|
+
retry
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @param error [GRPC::BadStatus]
|
|
52
|
+
# @return [Float, nil] Seconds from the error's RetryInfo detail, or nil when it has none
|
|
53
|
+
def retry_delay(error)
|
|
54
|
+
error.to_rpc_status&.details&.each do |any|
|
|
55
|
+
delay = any.unpack(::Google::Rpc::RetryInfo)&.retry_delay
|
|
56
|
+
return delay.seconds + (delay.nanos / 1e9) if delay
|
|
57
|
+
end
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -19,9 +19,12 @@ module HatchetSdkRest
|
|
|
19
19
|
DROP_NEWEST = "DROP_NEWEST".freeze
|
|
20
20
|
QUEUE_NEWEST = "QUEUE_NEWEST".freeze
|
|
21
21
|
GROUP_ROUND_ROBIN = "GROUP_ROUND_ROBIN".freeze
|
|
22
|
+
CANCEL_NEWEST = "CANCEL_NEWEST".freeze
|
|
23
|
+
CANCEL_QUEUED_EXCEPT_NEWEST = "CANCEL_QUEUED_EXCEPT_NEWEST".freeze
|
|
24
|
+
CANCEL_QUEUED_EXCEPT_OLDEST = "CANCEL_QUEUED_EXCEPT_OLDEST".freeze
|
|
22
25
|
|
|
23
26
|
def self.all_vars
|
|
24
|
-
@all_vars ||= [CANCEL_IN_PROGRESS, DROP_NEWEST, QUEUE_NEWEST, GROUP_ROUND_ROBIN].freeze
|
|
27
|
+
@all_vars ||= [CANCEL_IN_PROGRESS, DROP_NEWEST, QUEUE_NEWEST, GROUP_ROUND_ROBIN, CANCEL_NEWEST, CANCEL_QUEUED_EXCEPT_NEWEST, CANCEL_QUEUED_EXCEPT_OLDEST].freeze
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
# Builds the enum from string
|
|
@@ -20,9 +20,10 @@ module HatchetSdkRest
|
|
|
20
20
|
ORGANIZATION_SSO_ENABLED = "organization-sso-enabled".freeze
|
|
21
21
|
OPERATOR_DETAILS_ENABLED = "operator-details-enabled".freeze
|
|
22
22
|
CONCURRENCY_PAGE_ENABLED = "concurrency-page-enabled".freeze
|
|
23
|
+
RUNS_FILTER_SIDEBAR_ENABLED = "runs-filter-sidebar-enabled".freeze
|
|
23
24
|
|
|
24
25
|
def self.all_vars
|
|
25
|
-
@all_vars ||= [TENANT_LOG_WORKFLOW_FILTER_ENABLED, TRACE_MINIMAP_ENABLED, ORGANIZATION_SSO_ENABLED, OPERATOR_DETAILS_ENABLED, CONCURRENCY_PAGE_ENABLED].freeze
|
|
26
|
+
@all_vars ||= [TENANT_LOG_WORKFLOW_FILTER_ENABLED, TRACE_MINIMAP_ENABLED, ORGANIZATION_SSO_ENABLED, OPERATOR_DETAILS_ENABLED, CONCURRENCY_PAGE_ENABLED, RUNS_FILTER_SIDEBAR_ENABLED].freeze
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# Builds the enum from string
|
|
@@ -22,9 +22,12 @@ module HatchetSdkRest
|
|
|
22
22
|
CRON = "CRON".freeze
|
|
23
23
|
SCHEDULE = "SCHEDULE".freeze
|
|
24
24
|
INCOMING_WEBHOOK = "INCOMING_WEBHOOK".freeze
|
|
25
|
+
STREAM_TOPIC = "STREAM_TOPIC".freeze
|
|
26
|
+
STREAM_MESSAGE = "STREAM_MESSAGE".freeze
|
|
27
|
+
STREAM_RETENTION = "STREAM_RETENTION".freeze
|
|
25
28
|
|
|
26
29
|
def self.all_vars
|
|
27
|
-
@all_vars ||= [WORKER, WORKER_SLOT, EVENT, TASK_RUN, CRON, SCHEDULE, INCOMING_WEBHOOK].freeze
|
|
30
|
+
@all_vars ||= [WORKER, WORKER_SLOT, EVENT, TASK_RUN, CRON, SCHEDULE, INCOMING_WEBHOOK, STREAM_TOPIC, STREAM_MESSAGE, STREAM_RETENTION].freeze
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
# Builds the enum from string
|
|
@@ -40,9 +40,10 @@ module HatchetSdkRest
|
|
|
40
40
|
COULD_NOT_SEND_TO_WORKER = "COULD_NOT_SEND_TO_WORKER".freeze
|
|
41
41
|
DURABLE_EVICTED = "DURABLE_EVICTED".freeze
|
|
42
42
|
DURABLE_RESTORING = "DURABLE_RESTORING".freeze
|
|
43
|
+
BATCH_BUFFERED = "BATCH_BUFFERED".freeze
|
|
43
44
|
|
|
44
45
|
def self.all_vars
|
|
45
|
-
@all_vars ||= [REQUEUED_NO_WORKER, REQUEUED_RATE_LIMIT, SCHEDULING_TIMED_OUT, ASSIGNED, STARTED, FINISHED, FAILED, RETRYING, CANCELLED, TIMED_OUT, REASSIGNED, SLOT_RELEASED, TIMEOUT_REFRESHED, RETRIED_BY_USER, SENT_TO_WORKER, RATE_LIMIT_ERROR, ACKNOWLEDGED, CREATED, QUEUED, SKIPPED, WAITING_FOR_BATCH, BATCH_FLUSHED, COULD_NOT_SEND_TO_WORKER, DURABLE_EVICTED, DURABLE_RESTORING].freeze
|
|
46
|
+
@all_vars ||= [REQUEUED_NO_WORKER, REQUEUED_RATE_LIMIT, SCHEDULING_TIMED_OUT, ASSIGNED, STARTED, FINISHED, FAILED, RETRYING, CANCELLED, TIMED_OUT, REASSIGNED, SLOT_RELEASED, TIMEOUT_REFRESHED, RETRIED_BY_USER, SENT_TO_WORKER, RATE_LIMIT_ERROR, ACKNOWLEDGED, CREATED, QUEUED, SKIPPED, WAITING_FOR_BATCH, BATCH_FLUSHED, COULD_NOT_SEND_TO_WORKER, DURABLE_EVICTED, DURABLE_RESTORING, BATCH_BUFFERED].freeze
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
# Builds the enum from string
|
data/lib/hatchet/version.rb
CHANGED
data/lib/hatchet-sdk.rb
CHANGED
|
@@ -62,6 +62,7 @@ module Hatchet
|
|
|
62
62
|
require_relative "hatchet/contracts/v1/streams_pb"
|
|
63
63
|
require_relative "hatchet/contracts/v1/streams_services_pb"
|
|
64
64
|
|
|
65
|
+
require_relative "hatchet/clients/grpc/server_retry_delay"
|
|
65
66
|
require_relative "hatchet/clients/grpc/dispatcher"
|
|
66
67
|
require_relative "hatchet/clients/grpc/admin"
|
|
67
68
|
require_relative "hatchet/clients/grpc/event_client"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hatchet-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.12.
|
|
4
|
+
version: 0.12.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gabriel ruttner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -190,6 +190,7 @@ files:
|
|
|
190
190
|
- lib/hatchet/clients/grpc/admin.rb
|
|
191
191
|
- lib/hatchet/clients/grpc/dispatcher.rb
|
|
192
192
|
- lib/hatchet/clients/grpc/event_client.rb
|
|
193
|
+
- lib/hatchet/clients/grpc/server_retry_delay.rb
|
|
193
194
|
- lib/hatchet/clients/rest.rb
|
|
194
195
|
- lib/hatchet/clients/rest/.gitignore
|
|
195
196
|
- lib/hatchet/clients/rest/.gitlab-ci.yml
|
|
@@ -575,6 +576,7 @@ files:
|
|
|
575
576
|
- sig/hatchet/clients/grpc/admin.rbs
|
|
576
577
|
- sig/hatchet/clients/grpc/dispatcher.rbs
|
|
577
578
|
- sig/hatchet/clients/grpc/event_client.rbs
|
|
579
|
+
- sig/hatchet/clients/grpc/server_retry_delay.rbs
|
|
578
580
|
- sig/hatchet/clients/rest.rbs
|
|
579
581
|
- sig/hatchet/concurrency.rbs
|
|
580
582
|
- sig/hatchet/condition_converter.rbs
|