@@ -39,7 +39,7 @@ use temporalio_common::{
3939 worker:: WorkerTaskTypes ,
4040} ;
4141use temporalio_sdk:: {
42- ActivityOptions , SyncWorkflowContext , WorkflowContext , WorkflowResult ,
42+ ActivityCloseTimeouts , ActivityOptions , SyncWorkflowContext , WorkflowContext , WorkflowResult ,
4343 activities:: { ActivityContext , ActivityError } ,
4444 workflows,
4545} ;
@@ -60,16 +60,16 @@ impl ActivityLoadWf {
6060 . start_activity (
6161 StdActivities :: echo,
6262 input_str. clone ( ) ,
63- ActivityOptions {
64- activity_id : Some ( "act-1" . to_string ( ) ) ,
65- task_queue : Some ( tq ) ,
66- schedule_to_start_timeout : Some ( Duration :: from_secs ( 8 ) ) ,
67- start_to_close_timeout : Some ( Duration :: from_secs ( 8 ) ) ,
68- schedule_to_close_timeout : Some ( Duration :: from_secs ( 8 ) ) ,
69- heartbeat_timeout : Some ( Duration :: from_secs ( 8 ) ) ,
70- cancellation_type : ActivityCancellationType :: TryCancel ,
71- .. Default :: default ( )
72- } ,
63+ ActivityOptions :: with_close_timeouts ( ActivityCloseTimeouts :: Both {
64+ start_to_close : Duration :: from_secs ( 8 ) ,
65+ schedule_to_close : Duration :: from_secs ( 8 ) ,
66+ } )
67+ . activity_id ( "act-1" . to_string ( ) )
68+ . task_queue ( tq )
69+ . schedule_to_start_timeout ( Duration :: from_secs ( 8 ) )
70+ . heartbeat_timeout ( Duration :: from_secs ( 8 ) )
71+ . cancellation_type ( ActivityCancellationType :: TryCancel )
72+ . build ( ) ,
7373 )
7474 . await ?;
7575 assert_eq ! ( res, input_str) ;
@@ -129,11 +129,9 @@ impl ChunkyActivityWf {
129129 . start_activity (
130130 ChunkyActivities :: chunky_echo,
131131 input_str. clone ( ) ,
132- ActivityOptions {
133- activity_id : Some ( "act-1" . to_string ( ) ) ,
134- start_to_close_timeout : Some ( Duration :: from_secs ( 30 ) ) ,
135- ..Default :: default ( )
136- } ,
132+ ActivityOptions :: with_start_to_close_timeout ( Duration :: from_secs ( 30 ) )
133+ . activity_id ( "act-1" . to_string ( ) )
134+ . build ( ) ,
137135 )
138136 . await ?;
139137 assert_eq ! ( res, input_str) ;
@@ -222,10 +220,7 @@ impl WorkflowLoadWf {
222220 . start_activity (
223221 StdActivities :: echo,
224222 "hi!" . to_string ( ) ,
225- ActivityOptions {
226- start_to_close_timeout : Some ( Duration :: from_secs ( 5 ) ) ,
227- ..Default :: default ( )
228- } ,
223+ ActivityOptions :: start_to_close_timeout ( Duration :: from_secs ( 5 ) ) ,
229224 )
230225 . await ;
231226 ctx. timer ( Duration :: from_secs ( 1 ) ) . await ;
@@ -439,10 +434,7 @@ impl PollerLoadWf {
439434 . start_activity (
440435 JitteryActivities :: jittery_echo,
441436 "hi!" . to_string ( ) ,
442- ActivityOptions {
443- start_to_close_timeout : Some ( Duration :: from_secs ( 5 ) ) ,
444- ..Default :: default ( )
445- } ,
437+ ActivityOptions :: start_to_close_timeout ( Duration :: from_secs ( 5 ) ) ,
446438 )
447439 . await ;
448440 }
0 commit comments