From f409791ae0ea5a80dfa0aa55e171513ff0d5de7e Mon Sep 17 00:00:00 2001 From: Maciej Dudkowski Date: Thu, 18 Sep 2025 16:15:53 -0400 Subject: [PATCH 1/2] Added retry policy to activity info --- temporalio/ext/sdk-core | 2 +- temporalio/lib/temporalio/activity/info.rb | 5 +++++ temporalio/lib/temporalio/internal/worker/activity_worker.rb | 1 + temporalio/lib/temporalio/testing/activity_environment.rb | 1 + temporalio/sig/temporalio/activity/info.rbs | 2 ++ temporalio/test/test.rb | 5 +++-- temporalio/test/worker_activity_test.rb | 2 +- 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/temporalio/ext/sdk-core b/temporalio/ext/sdk-core index 4078190b..b3acbe2e 160000 --- a/temporalio/ext/sdk-core +++ b/temporalio/ext/sdk-core @@ -1 +1 @@ -Subproject commit 4078190b99ef16691512bc58e1da2d109419bc93 +Subproject commit b3acbe2e83c2a2b798aeb3d0261d75a721988667 diff --git a/temporalio/lib/temporalio/activity/info.rb b/temporalio/lib/temporalio/activity/info.rb index f4eaf441..f5332d42 100644 --- a/temporalio/lib/temporalio/activity/info.rb +++ b/temporalio/lib/temporalio/activity/info.rb @@ -13,6 +13,7 @@ module Activity :heartbeat_timeout, :local?, :priority, + :retry_policy, :raw_heartbeat_details, :schedule_to_close_timeout, :scheduled_time, @@ -42,6 +43,10 @@ module Activity # @return [Boolean] Whether the activity is a local activity or not. # @!attribute priority # @return [Priority] The priority of this activity. + # @!attribute retry_policy + # @return [RetryPolicy, nil] Retry policy for the activity. Note that the server may have set a different policy + # than the one provided when scheduling the activity. If the value is None, it means the server didn't send + # information about retry policy (e.g. due to old server version), but it may still be defined server-side. # @!attribute raw_heartbeat_details # @return [Array] Raw details from the last heartbeat of the last attempt. Can use # {heartbeat_details} to get lazily-converted values. diff --git a/temporalio/lib/temporalio/internal/worker/activity_worker.rb b/temporalio/lib/temporalio/internal/worker/activity_worker.rb index 2b157205..46648b7a 100644 --- a/temporalio/lib/temporalio/internal/worker/activity_worker.rb +++ b/temporalio/lib/temporalio/internal/worker/activity_worker.rb @@ -185,6 +185,7 @@ def execute_activity(task_token, defn, start) payloads = codec.decode(payloads) if codec payloads.map { |p| Temporalio::Converters::RawValue.new(p) } end, + retry_policy: (RetryPolicy._from_proto(start.retry_policy) if start.retry_policy), schedule_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.schedule_to_close_timeout), scheduled_time: Internal::ProtoUtils.timestamp_to_time(start.scheduled_time) || raise, # Never nil start_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.start_to_close_timeout), diff --git a/temporalio/lib/temporalio/testing/activity_environment.rb b/temporalio/lib/temporalio/testing/activity_environment.rb index 1f275a11..001fc2a6 100644 --- a/temporalio/lib/temporalio/testing/activity_environment.rb +++ b/temporalio/lib/temporalio/testing/activity_environment.rb @@ -25,6 +25,7 @@ def self.default_info local?: false, priority: Temporalio::Priority.default, raw_heartbeat_details: [], + retry_policy: RetryPolicy.new, schedule_to_close_timeout: 1.0, scheduled_time: Time.at(0), start_to_close_timeout: 1.0, diff --git a/temporalio/sig/temporalio/activity/info.rbs b/temporalio/sig/temporalio/activity/info.rbs index cfb4dd30..3e1a673f 100644 --- a/temporalio/sig/temporalio/activity/info.rbs +++ b/temporalio/sig/temporalio/activity/info.rbs @@ -9,6 +9,7 @@ module Temporalio attr_reader local?: bool attr_reader priority: Temporalio::Priority attr_reader raw_heartbeat_details: Array[Converters::RawValue] + attr_reader retry_policy: RetryPolicy? attr_reader schedule_to_close_timeout: Float? attr_reader scheduled_time: Time attr_reader start_to_close_timeout: Float? @@ -29,6 +30,7 @@ module Temporalio local?: bool, priority: Temporalio::Priority?, raw_heartbeat_details: Array[Converters::RawValue], + retry_policy: RetryPolicy?, schedule_to_close_timeout: Float?, scheduled_time: Time, start_to_close_timeout: Float?, diff --git a/temporalio/test/test.rb b/temporalio/test/test.rb index c780483e..b287c039 100644 --- a/temporalio/test/test.rb +++ b/temporalio/test/test.rb @@ -143,7 +143,8 @@ class TestEnvironment def initialize # Start workflow env for an existing server if env vars present - if ENV['TEMPORAL_TEST_CLIENT_TARGET_HOST'].blank? + target_host = ENV['TEMPORAL_TEST_CLIENT_TARGET_HOST'] + if target_host.nil? || target_host.empty? @server = Temporalio::Testing::WorkflowEnvironment.start_local( logger: Logger.new($stdout), dev_server_extra_args: [ @@ -162,7 +163,7 @@ def initialize end else client = Temporalio::Client.connect( - ENV.fetch('TEMPORAL_TEST_CLIENT_TARGET_HOST'), + target_host, ENV['TEMPORAL_TEST_CLIENT_TARGET_NAMESPACE'] || 'default', logger: Logger.new($stdout) ) diff --git a/temporalio/test/worker_activity_test.rb b/temporalio/test/worker_activity_test.rb index d39bd4f8..9f2a3a68 100644 --- a/temporalio/test/worker_activity_test.rb +++ b/temporalio/test/worker_activity_test.rb @@ -264,9 +264,9 @@ def test_info assert_equal 1, info.attempt refute_nil info.current_attempt_scheduled_time assert_equal false, info.local? + refute_nil info.retry_policy refute_nil info.schedule_to_close_timeout refute_nil info.scheduled_time - refute_nil info.current_attempt_scheduled_time refute_nil info.start_to_close_timeout refute_nil info.started_time refute_nil info.task_queue From 607b756d988b158c04ee08f65171a7519761c570 Mon Sep 17 00:00:00 2001 From: Maciej Dudkowski Date: Fri, 19 Sep 2025 12:30:12 -0400 Subject: [PATCH 2/2] Fixed CI error --- temporalio/test/test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/temporalio/test/test.rb b/temporalio/test/test.rb index b287c039..38334ccc 100644 --- a/temporalio/test/test.rb +++ b/temporalio/test/test.rb @@ -143,8 +143,8 @@ class TestEnvironment def initialize # Start workflow env for an existing server if env vars present - target_host = ENV['TEMPORAL_TEST_CLIENT_TARGET_HOST'] - if target_host.nil? || target_host.empty? + target_host = ENV.fetch('TEMPORAL_TEST_CLIENT_TARGET_HOST', '') + if target_host.empty? @server = Temporalio::Testing::WorkflowEnvironment.start_local( logger: Logger.new($stdout), dev_server_extra_args: [