Skip to content

Commit c2ca06f

Browse files
committed
plumb keep-original-wf-id
1 parent ec8412c commit c2ca06f

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

temporalio/lib/temporalio/client/schedule.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@ def _to_proto
716716
Policy = Data.define(
717717
:overlap,
718718
:catchup_window,
719-
:pause_on_failure
719+
:pause_on_failure,
720+
:keep_original_workflow_id
720721
)
721722

722723
# Policies of a schedule.
@@ -728,6 +729,8 @@ def _to_proto
728729
# @!attribute pause_on_failure
729730
# @return [Boolean] Whether to pause the schedule if an action fails or times out. Note: For workflows, this
730731
# only applies after all retries have been exhausted.
732+
# @!attribute keep_original_workflow_id
733+
# @return [Boolean] Whether to keep the original workflow ID without appending a timestamp for uniqueness.
731734
class Policy
732735
# @!visibility private
733736
def self._from_proto(raw_policies)
@@ -736,7 +739,8 @@ def self._from_proto(raw_policies)
736739
raw_policies.overlap_policy,
737740
zero_means_nil: true),
738741
catchup_window: Internal::ProtoUtils.duration_to_seconds(raw_policies.catchup_window) || raise, # Never nil
739-
pause_on_failure: raw_policies.pause_on_failure
742+
pause_on_failure: raw_policies.pause_on_failure,
743+
keep_original_workflow_id: raw_policies.keep_original_workflow_id
740744
)
741745
end
742746

@@ -747,10 +751,13 @@ def self._from_proto(raw_policies)
747751
# missed actions.
748752
# @param pause_on_failure [Boolean] Whether to pause the schedule if an action fails or times out. Note: For
749753
# workflows, this only applies after all retries have been exhausted.
754+
# @param keep_original_workflow_id [Boolean] Whether to keep the original workflow ID without appending a
755+
# timestamp for uniqueness.
750756
def initialize(
751757
overlap: OverlapPolicy::SKIP,
752758
catchup_window: 365 * 24 * 60 * 60.0,
753-
pause_on_failure: false
759+
pause_on_failure: false,
760+
keep_original_workflow_id: false
754761
)
755762
super
756763
end
@@ -760,7 +767,8 @@ def _to_proto
760767
Api::Schedule::V1::SchedulePolicies.new(
761768
overlap_policy: overlap,
762769
catchup_window: Internal::ProtoUtils.seconds_to_duration(catchup_window),
763-
pause_on_failure:
770+
pause_on_failure:,
771+
keep_original_workflow_id:
764772
)
765773
end
766774
end

temporalio/sig/temporalio/client/schedule.rbs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,15 @@ module Temporalio
239239
attr_reader overlap: OverlapPolicy::enum
240240
attr_reader catchup_window: duration
241241
attr_reader pause_on_failure: bool
242+
attr_reader keep_original_workflow_id: bool
242243

243244
def self._from_proto: (untyped raw_policies) -> Policy
244245

245246
def initialize: (
246247
?overlap: OverlapPolicy::enum,
247248
?catchup_window: duration,
248-
?pause_on_failure: bool
249+
?pause_on_failure: bool,
250+
?keep_original_workflow_id: bool
249251
) -> void
250252

251253
def _to_proto: -> untyped
@@ -332,4 +334,4 @@ module Temporalio
332334
end
333335
end
334336
end
335-
end
337+
end

temporalio/test/client_schedule_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def test_basics # rubocop:disable Metrics/AbcSize
5353
policy: Temporalio::Client::Schedule::Policy.new(
5454
overlap: Temporalio::Client::Schedule::OverlapPolicy::BUFFER_ONE,
5555
catchup_window: 5 * 60.0,
56-
pause_on_failure: true
56+
pause_on_failure: true,
57+
keep_original_workflow_id: true
5758
),
5859
state: Temporalio::Client::Schedule::State.new(
5960
note: 'sched note 1',
@@ -124,6 +125,7 @@ def test_basics # rubocop:disable Metrics/AbcSize
124125
new_schedule = Temporalio::Client::Schedule.new(
125126
action:,
126127
spec: Temporalio::Client::Schedule::Spec.new,
128+
policy: Temporalio::Client::Schedule::Policy.new(keep_original_workflow_id: true),
127129
state: Temporalio::Client::Schedule::State.new(paused: true)
128130
)
129131
handle.update { Temporalio::Client::Schedule::Update.new(schedule: new_schedule) }
@@ -170,6 +172,7 @@ def test_basics # rubocop:disable Metrics/AbcSize
170172
# Check results
171173
exec = desc.info.recent_actions.first&.action #: Temporalio::Client::Schedule::ActionExecution::StartWorkflow
172174
assert_instance_of Temporalio::Client::Schedule::ActionExecution::StartWorkflow, exec
175+
assert_equal action.id, exec.workflow_id
173176
assert_equal 'some-result',
174177
env.client.workflow_handle(exec.workflow_id,
175178
first_execution_run_id: exec.first_execution_run_id).result

0 commit comments

Comments
 (0)