@@ -17,6 +17,7 @@ package workflow
1717import (
1818 "context"
1919 "encoding/json"
20+ "time"
2021
2122 "google.golang.org/protobuf/types/known/wrapperspb"
2223
@@ -38,7 +39,16 @@ func (wfac *ActivityContext) Context() context.Context {
3839type callActivityOption func (* callActivityOptions ) error
3940
4041type callActivityOptions struct {
41- rawInput * wrapperspb.StringValue
42+ rawInput * wrapperspb.StringValue
43+ retryPolicy * ActivityRetryPolicy
44+ }
45+
46+ type ActivityRetryPolicy struct {
47+ MaxAttempts int
48+ InitialRetryInterval time.Duration
49+ BackoffCoefficient float64
50+ MaxRetryInterval time.Duration
51+ RetryTimeout time.Duration
4252}
4353
4454// ActivityInput is an option to pass a JSON-serializable input
@@ -61,6 +71,26 @@ func ActivityRawInput(input string) callActivityOption {
6171 }
6272}
6373
74+ func RetryPolicy (policy ActivityRetryPolicy ) callActivityOption {
75+ return func (opts * callActivityOptions ) error {
76+ opts .retryPolicy = & policy
77+ return nil
78+ }
79+ }
80+
81+ func (opts * callActivityOptions ) getRetryPolicy () * task.ActivityRetryPolicy {
82+ if opts .retryPolicy == nil {
83+ return nil
84+ }
85+ return & task.ActivityRetryPolicy {
86+ MaxAttempts : opts .retryPolicy .MaxAttempts ,
87+ InitialRetryInterval : opts .retryPolicy .InitialRetryInterval ,
88+ BackoffCoefficient : opts .retryPolicy .BackoffCoefficient ,
89+ MaxRetryInterval : opts .retryPolicy .MaxRetryInterval ,
90+ RetryTimeout : opts .retryPolicy .RetryTimeout ,
91+ }
92+ }
93+
6494func marshalData (input any ) ([]byte , error ) {
6595 if input == nil {
6696 return nil , nil
0 commit comments