hatchet-sdk 0.8.1 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be1774bd178f9f0894c60a509906ffebd7fe8f1a46e6cd115d9c7697a3dd53a6
4
- data.tar.gz: 4b95d1af25208d79c676971b591a5eb48a9e303a7da8b471eef4c211c88c082d
3
+ metadata.gz: bf12b2683a7b26125e459a66b28acfa0d0c04cc5a4b148cadcce6a29f69b53ea
4
+ data.tar.gz: ea2fc0114f0a8d236d899b1713c85e5383bf83ab19cc0099020d680f35501db0
5
5
  SHA512:
6
- metadata.gz: afc688f0fefb4dfb586930df4fa9565fe4b19fe40ccd0420b023ed1955d0f0d324cf4f21e77d015c0890d99372ff59169514ece787b682e20859eb3595a1341b
7
- data.tar.gz: dddfa86c822f506aa768fb233243a063e8f4b405f7fa6a2295474ae2e65b2d8bcf4ae59490cd8bd0f9b13d20c561e755217dda95402df91597d780b9e0dd3708
6
+ metadata.gz: fd9e284829bb0ede7127685699cd79e0c5283d693aee9bc5e6e201cd2518e20c08e83e884054a3325bda3c0435e5743ff35137f6ebb44cbeea9383b83617250b
7
+ data.tar.gz: 7ac930e2413632481a339e892cbc932fc205d15c6012a2f9e4ea43fe002282c40a24a6f47d555c1fd222c285ee16a2c5155595a2405c89fd3c975ce86e77a32c
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ 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.9.0] - 2026-09-23
9
+
10
+ ### Added
11
+
12
+ - Added `pause` and `unpause` methods to the workflows client (`hatchet.workflows.pause(workflow_id, queue_ttl:)`) and to workflows (`workflow.pause(queue_ttl:)`). `queue_ttl` is how long runs stay queued while the workflow is paused, in seconds or as a duration string, and the behavior (`QUEUE` or `DROP`) for cron and scheduled runs triggered while paused can optionally be set, both defaulting to `QUEUE`.
13
+
8
14
  ## [0.8.1] - 2026-10-05
9
15
 
10
16
  ### Fixed
@@ -82,6 +82,51 @@ module Hatchet
82
82
  def delete(workflow_id)
83
83
  @workflow_api.workflow_delete(workflow_id)
84
84
  end
85
+
86
+ # Pause a workflow. While paused, new runs of the workflow are queued but not started.
87
+ #
88
+ # @param workflow_id [String] The ID of the workflow to pause
89
+ # @param queue_ttl [Integer, String] How long runs stay queued while the workflow is paused before they are dropped, in seconds or as a duration string (e.g. "1h30m")
90
+ # @param paused_workflow_cron_run_queue_behavior [String] The behavior of cron runs triggered while the workflow is paused ("QUEUE" or "DROP")
91
+ # @param paused_workflow_scheduled_run_queue_behavior [String] The behavior of scheduled runs triggered while the workflow is paused ("QUEUE" or "DROP")
92
+ # @return [HatchetSdkRest::Workflow] The updated workflow
93
+ # @raise [HatchetSdkRest::ApiError] If the API request fails
94
+ # @example
95
+ # hatchet.workflows.pause("workflow-123", queue_ttl: 3600)
96
+ def pause(
97
+ workflow_id,
98
+ queue_ttl:,
99
+ paused_workflow_cron_run_queue_behavior: HatchetSdkRest::WorkflowPauseScheduledCronRunQueueBehavior::QUEUE,
100
+ paused_workflow_scheduled_run_queue_behavior: HatchetSdkRest::WorkflowPauseScheduledCronRunQueueBehavior::QUEUE
101
+ )
102
+ pause_request = HatchetSdkRest::PauseWorkflowRequestPause.new(
103
+ action: "pause",
104
+ paused_workflow_queue_ttl: queue_ttl.is_a?(String) ? queue_ttl : "#{queue_ttl}s",
105
+ paused_workflow_cron_run_queue_behavior: paused_workflow_cron_run_queue_behavior,
106
+ paused_workflow_scheduled_run_queue_behavior: paused_workflow_scheduled_run_queue_behavior,
107
+ )
108
+
109
+ @workflow_api.workflow_update(
110
+ workflow_id,
111
+ HatchetSdkRest::WorkflowUpdateRequest.new(pause: pause_request),
112
+ )
113
+ end
114
+
115
+ # Unpause a workflow
116
+ #
117
+ # @param workflow_id [String] The ID of the workflow to unpause
118
+ # @return [HatchetSdkRest::Workflow] The updated workflow
119
+ # @raise [HatchetSdkRest::ApiError] If the API request fails
120
+ # @example
121
+ # hatchet.workflows.unpause("workflow-123")
122
+ def unpause(workflow_id)
123
+ @workflow_api.workflow_update(
124
+ workflow_id,
125
+ HatchetSdkRest::WorkflowUpdateRequest.new(
126
+ pause: HatchetSdkRest::PauseWorkflowRequestUnpause.new(action: "unpause"),
127
+ ),
128
+ )
129
+ end
85
130
  end
86
131
  end
87
132
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hatchet
4
- VERSION = "0.8.1"
4
+ VERSION = "0.9.0"
5
5
  end
@@ -348,6 +348,29 @@ module Hatchet
348
348
  )
349
349
  end
350
350
 
351
+ # Pause this workflow. While paused, new runs of the workflow are queued but not started.
352
+ #
353
+ # @param queue_ttl [Integer, String] How long runs stay queued while the workflow is paused before they are dropped, in seconds or as a duration string (e.g. "1h30m")
354
+ # @param paused_workflow_cron_run_queue_behavior [String] The behavior of cron runs triggered while the workflow is paused ("QUEUE" or "DROP")
355
+ # @param paused_workflow_scheduled_run_queue_behavior [String] The behavior of scheduled runs triggered while the workflow is paused ("QUEUE" or "DROP")
356
+ # @return [HatchetSdkRest::Workflow] The updated workflow
357
+ # @raise [Hatchet::Error] If no client is associated with the workflow
358
+ def pause(queue_ttl:, **opts)
359
+ raise Error, "No client associated with workflow #{@name}" unless @client
360
+
361
+ @client.workflows.pause(id, queue_ttl: queue_ttl, **opts)
362
+ end
363
+
364
+ # Unpause this workflow.
365
+ #
366
+ # @return [HatchetSdkRest::Workflow] The updated workflow
367
+ # @raise [Hatchet::Error] If no client is associated with the workflow
368
+ def unpause
369
+ raise Error, "No client associated with workflow #{@name}" unless @client
370
+
371
+ @client.workflows.unpause(id)
372
+ end
373
+
351
374
  private
352
375
 
353
376
  # Resolve the workflow UUID by looking up the workflow by name via the REST API.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatchet-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gabriel ruttner