Skip to content

Commit 1aa91a2

Browse files
authored
Added retry policy to activity info (#341)
1 parent 3a8a977 commit 1aa91a2

File tree

7 files changed

+14
-4
lines changed

7 files changed

+14
-4
lines changed

temporalio/lib/temporalio/activity/info.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Activity
1313
:heartbeat_timeout,
1414
:local?,
1515
:priority,
16+
:retry_policy,
1617
:raw_heartbeat_details,
1718
:schedule_to_close_timeout,
1819
:scheduled_time,
@@ -42,6 +43,10 @@ module Activity
4243
# @return [Boolean] Whether the activity is a local activity or not.
4344
# @!attribute priority
4445
# @return [Priority] The priority of this activity.
46+
# @!attribute retry_policy
47+
# @return [RetryPolicy, nil] Retry policy for the activity. Note that the server may have set a different policy
48+
# than the one provided when scheduling the activity. If the value is None, it means the server didn't send
49+
# information about retry policy (e.g. due to old server version), but it may still be defined server-side.
4550
# @!attribute raw_heartbeat_details
4651
# @return [Array<Converter::RawValue>] Raw details from the last heartbeat of the last attempt. Can use
4752
# {heartbeat_details} to get lazily-converted values.

temporalio/lib/temporalio/internal/worker/activity_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def execute_activity(task_token, defn, start)
185185
payloads = codec.decode(payloads) if codec
186186
payloads.map { |p| Temporalio::Converters::RawValue.new(p) }
187187
end,
188+
retry_policy: (RetryPolicy._from_proto(start.retry_policy) if start.retry_policy),
188189
schedule_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.schedule_to_close_timeout),
189190
scheduled_time: Internal::ProtoUtils.timestamp_to_time(start.scheduled_time) || raise, # Never nil
190191
start_to_close_timeout: Internal::ProtoUtils.duration_to_seconds(start.start_to_close_timeout),

temporalio/lib/temporalio/testing/activity_environment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def self.default_info
2525
local?: false,
2626
priority: Temporalio::Priority.default,
2727
raw_heartbeat_details: [],
28+
retry_policy: RetryPolicy.new,
2829
schedule_to_close_timeout: 1.0,
2930
scheduled_time: Time.at(0),
3031
start_to_close_timeout: 1.0,

temporalio/sig/temporalio/activity/info.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Temporalio
99
attr_reader local?: bool
1010
attr_reader priority: Temporalio::Priority
1111
attr_reader raw_heartbeat_details: Array[Converters::RawValue]
12+
attr_reader retry_policy: RetryPolicy?
1213
attr_reader schedule_to_close_timeout: Float?
1314
attr_reader scheduled_time: Time
1415
attr_reader start_to_close_timeout: Float?
@@ -29,6 +30,7 @@ module Temporalio
2930
local?: bool,
3031
priority: Temporalio::Priority?,
3132
raw_heartbeat_details: Array[Converters::RawValue],
33+
retry_policy: RetryPolicy?,
3234
schedule_to_close_timeout: Float?,
3335
scheduled_time: Time,
3436
start_to_close_timeout: Float?,

temporalio/test/test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ class TestEnvironment
143143

144144
def initialize
145145
# Start workflow env for an existing server if env vars present
146-
if ENV['TEMPORAL_TEST_CLIENT_TARGET_HOST'].blank?
146+
target_host = ENV.fetch('TEMPORAL_TEST_CLIENT_TARGET_HOST', '')
147+
if target_host.empty?
147148
@server = Temporalio::Testing::WorkflowEnvironment.start_local(
148149
logger: Logger.new($stdout),
149150
dev_server_extra_args: [
@@ -162,7 +163,7 @@ def initialize
162163
end
163164
else
164165
client = Temporalio::Client.connect(
165-
ENV.fetch('TEMPORAL_TEST_CLIENT_TARGET_HOST'),
166+
target_host,
166167
ENV['TEMPORAL_TEST_CLIENT_TARGET_NAMESPACE'] || 'default',
167168
logger: Logger.new($stdout)
168169
)

temporalio/test/worker_activity_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ def test_info
264264
assert_equal 1, info.attempt
265265
refute_nil info.current_attempt_scheduled_time
266266
assert_equal false, info.local?
267+
refute_nil info.retry_policy
267268
refute_nil info.schedule_to_close_timeout
268269
refute_nil info.scheduled_time
269-
refute_nil info.current_attempt_scheduled_time
270270
refute_nil info.start_to_close_timeout
271271
refute_nil info.started_time
272272
refute_nil info.task_queue

0 commit comments

Comments
 (0)