@@ -38,12 +38,12 @@ import (
38
38
)
39
39
40
40
type (
41
- // ActivityType identifies a activity type.
41
+ // ActivityType identifies an activity type.
42
42
ActivityType struct {
43
43
Name string
44
44
}
45
45
46
- // ActivityInfo contains information about currently executing activity.
46
+ // ActivityInfo contains information about a currently executing activity.
47
47
ActivityInfo struct {
48
48
TaskToken []byte
49
49
WorkflowType * WorkflowType
60
60
IsLocalActivity bool // true if it is a local activity
61
61
}
62
62
63
- // RegisterActivityOptions consists of options for registering an activity
63
+ // RegisterActivityOptions consists of options for registering an activity.
64
64
RegisterActivityOptions struct {
65
65
// When an activity is a function the name is an actual activity type name.
66
66
// When an activity is part of a structure then each member of the structure becomes an activity with
@@ -82,22 +82,22 @@ type (
82
82
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
83
83
// subjected to change in the future.
84
84
ActivityOptions struct {
85
- // TaskQueue that the activity needs to be scheduled on.
86
- // optional : The default task queue with the same name as the workflow task queue.
85
+ // TaskQueue - Name of the task queue that the activity needs to be scheduled on.
86
+ // Optional : The default task queue with the same name as the workflow task queue.
87
87
TaskQueue string
88
88
89
- // ScheduleToCloseTimeout - Total time that a workflow is willing to wait for Activity to complete.
89
+ // ScheduleToCloseTimeout - Total time that a workflow is willing to wait for an Activity to complete.
90
90
// ScheduleToCloseTimeout limits the total time of an Activity's execution including retries
91
91
// (use StartToCloseTimeout to limit the time of a single attempt).
92
92
// The zero value of this uses default value.
93
- // Either this option or StartToClose is required: Defaults to unlimited.
93
+ // Either this option or StartToCloseTimeout is required: Defaults to unlimited.
94
94
ScheduleToCloseTimeout time.Duration
95
95
96
96
// ScheduleToStartTimeout - Time that the Activity Task can stay in the Task Queue before it is picked up by
97
97
// a Worker. Do not specify this timeout unless using host specific Task Queues for Activity Tasks are being
98
- // used for routing. In almost all situations that don't involve routing activities to specific hosts it is
98
+ // used for routing. In almost all situations that don't involve routing activities to specific hosts, it is
99
99
// better to rely on the default value.
100
- // ScheduleToStartTimeout is always non-retryable. Retrying after this timeout doesn't make sense as it would
100
+ // ScheduleToStartTimeout is always non-retryable. Retrying after this timeout doesn't make sense, as it would
101
101
// just put the Activity Task back into the same Task Queue.
102
102
// Optional: Defaults to unlimited.
103
103
ScheduleToStartTimeout time.Duration
@@ -107,7 +107,7 @@ type (
107
107
// to detect that an Activity that didn't complete on time. So this timeout should be as short as the longest
108
108
// possible execution of the Activity body. Potentially long running Activities must specify HeartbeatTimeout
109
109
// and call Activity.RecordHeartbeat(ctx, "my-heartbeat") periodically for timely failure detection.
110
- // Either this option or ScheduleToClose is required: Defaults to the ScheduleToCloseTimeout value.
110
+ // Either this option or ScheduleToCloseTimeout is required: Defaults to the ScheduleToCloseTimeout value.
111
111
StartToCloseTimeout time.Duration
112
112
113
113
// HeartbeatTimeout - Heartbeat interval. Activity must call Activity.RecordHeartbeat(ctx, "my-heartbeat")
@@ -120,112 +120,111 @@ type (
120
120
WaitForCancellation bool
121
121
122
122
// ActivityID - Business level activity ID, this is not needed for most of the cases if you have
123
- // to specify this then talk to temporal team. This is something will be done in future.
123
+ // to specify this then talk to the temporal team. This is something will be done in the future.
124
124
// Optional: default empty string
125
125
ActivityID string
126
126
127
- // RetryPolicy specifies how to retry an Activity if an error occurs.
127
+ // RetryPolicy - Specifies how to retry an Activity if an error occurs.
128
128
// More details are available at docs.temporal.io.
129
- // RetryPolicy is optional. If one is not specified a default RetryPolicy is provided by the server.
129
+ // RetryPolicy is optional. If one is not specified, a default RetryPolicy is provided by the server.
130
130
// The default RetryPolicy provided by the server specifies:
131
131
// - InitialInterval of 1 second
132
132
// - BackoffCoefficient of 2.0
133
133
// - MaximumInterval of 100 x InitialInterval
134
134
// - MaximumAttempts of 0 (unlimited)
135
- // To disable retries set MaximumAttempts to 1.
135
+ // To disable retries, set MaximumAttempts to 1.
136
136
// The default RetryPolicy provided by the server can be overridden by the dynamic config.
137
137
RetryPolicy * RetryPolicy
138
138
139
- // If true, will not request eager execution regardless of worker settings.
139
+ // If true, eager execution will not be requested, regardless of worker settings.
140
140
// If false, eager execution may still be disabled at the worker level or
141
- // eager execution may not be requested due to lack of available slots.
141
+ // may not be requested due to lack of available slots.
142
142
//
143
143
// Eager activity execution means the server returns requested eager
144
- // activities directly from the workflow task back to this worker which is
145
- // faster than non-eager which may be dispatched to a separate worker.
144
+ // activities directly from the workflow task back to this worker. This is
145
+ // faster than non-eager, which may be dispatched to a separate worker.
146
146
DisableEagerExecution bool
147
147
148
- // VersioningIntent specifies whether this activity should run on a worker with a compatible
148
+ // VersioningIntent - Specifies whether this activity should run on a worker with a compatible
149
149
// build ID or not. See temporal.VersioningIntent.
150
150
// WARNING: Worker versioning is currently experimental
151
151
VersioningIntent VersioningIntent
152
152
}
153
153
154
154
// LocalActivityOptions stores local activity specific parameters that will be stored inside of a context.
155
155
LocalActivityOptions struct {
156
- // ScheduleToCloseTimeout - The end to end timeout for the local activity including retries.
156
+ // ScheduleToCloseTimeout - The end to end timeout for the local activity, including retries.
157
157
// At least one of ScheduleToCloseTimeout or StartToCloseTimeout is required.
158
- // defaults to StartToCloseTimeout if not set.
158
+ // Defaults to StartToCloseTimeout if not set.
159
159
ScheduleToCloseTimeout time.Duration
160
160
161
161
// StartToCloseTimeout - The timeout for a single execution of the local activity.
162
162
// At least one of ScheduleToCloseTimeout or StartToCloseTimeout is required.
163
- // defaults to ScheduleToCloseTimeout if not set.
163
+ // Defaults to ScheduleToCloseTimeout if not set.
164
164
StartToCloseTimeout time.Duration
165
165
166
- // RetryPolicy specify how to retry activity if error happens.
166
+ // RetryPolicy - Specify how to retry activity if error happens.
167
167
// Optional: default is to retry according to the default retry policy up to ScheduleToCloseTimeout
168
168
// with 1sec initial delay between retries and 2x backoff.
169
169
RetryPolicy * RetryPolicy
170
170
}
171
171
)
172
172
173
- // GetActivityInfo returns information about currently executing activity.
173
+ // GetActivityInfo returns information about the currently executing activity.
174
174
func GetActivityInfo (ctx context.Context ) ActivityInfo {
175
175
return getActivityOutboundInterceptor (ctx ).GetInfo (ctx )
176
176
}
177
177
178
- // HasHeartbeatDetails checks if there is heartbeat details from last attempt.
178
+ // HasHeartbeatDetails checks if there are heartbeat details from last attempt.
179
179
func HasHeartbeatDetails (ctx context.Context ) bool {
180
180
return getActivityOutboundInterceptor (ctx ).HasHeartbeatDetails (ctx )
181
181
}
182
182
183
- // IsActivity check if the context is an activity context from a normal or local activity.
183
+ // IsActivity checks if the context is an activity context from a normal or local activity.
184
184
func IsActivity (ctx context.Context ) bool {
185
185
a := ctx .Value (activityInterceptorContextKey )
186
186
return a != nil
187
187
}
188
188
189
- // GetHeartbeatDetails extract heartbeat details from last failed attempt. This is used in combination with retry policy.
190
- // An activity could be scheduled with an optional retry policy on ActivityOptions. If the activity failed then server
191
- // would attempt to dispatch another activity task to retry according to the retry policy. If there was heartbeat
189
+ // GetHeartbeatDetails extracts heartbeat details from the last failed attempt. This is used in combination with the retry policy.
190
+ // An activity could be scheduled with an optional retry policy on ActivityOptions. If the activity failed, then server
191
+ // would attempt to dispatch another activity task to retry according to the retry policy. If there were heartbeat
192
192
// details reported by activity from the failed attempt, the details would be delivered along with the activity task for
193
- // retry attempt. Activity could extract the details by GetHeartbeatDetails() and resume from the progress .
193
+ // the retry attempt. An activity can extract the details from GetHeartbeatDetails() and resume progress from there .
194
194
//
195
- // Note, values should not be reused for extraction here because merging on top
196
- // of existing values may result in unexpected behavior similar to
197
- // json.Unmarshal.
195
+ // Note: Values should not be reused for extraction here because merging on top
196
+ // of existing values may result in unexpected behavior similar to json.Unmarshal.
198
197
func GetHeartbeatDetails (ctx context.Context , d ... interface {}) error {
199
198
return getActivityOutboundInterceptor (ctx ).GetHeartbeatDetails (ctx , d ... )
200
199
}
201
200
202
- // GetActivityLogger returns a logger that can be used in activity
201
+ // GetActivityLogger returns a logger that can be used in the activity.
203
202
func GetActivityLogger (ctx context.Context ) log.Logger {
204
203
return getActivityOutboundInterceptor (ctx ).GetLogger (ctx )
205
204
}
206
205
207
- // GetActivityMetricsHandler returns a metrics handler that can be used in activity
206
+ // GetActivityMetricsHandler returns a metrics handler that can be used in the activity.
208
207
func GetActivityMetricsHandler (ctx context.Context ) metrics.Handler {
209
208
return getActivityOutboundInterceptor (ctx ).GetMetricsHandler (ctx )
210
209
}
211
210
212
211
// GetWorkerStopChannel returns a read-only channel. The closure of this channel indicates the activity worker is stopping.
213
212
// When the worker is stopping, it will close this channel and wait until the worker stop timeout finishes. After the timeout
214
- // hit , the worker will cancel the activity context and then exit. The timeout can be defined by worker option: WorkerStopTimeout.
215
- // Use this channel to handle activity graceful exit when the activity worker stops.
213
+ // hits , the worker will cancel the activity context and then exit. The timeout can be defined by worker option: WorkerStopTimeout.
214
+ // Use this channel to handle a graceful activity exit when the activity worker stops.
216
215
func GetWorkerStopChannel (ctx context.Context ) <- chan struct {} {
217
216
return getActivityOutboundInterceptor (ctx ).GetWorkerStopChannel (ctx )
218
217
}
219
218
220
- // RecordActivityHeartbeat sends heartbeat for the currently executing activity
221
- // If the activity is either canceled (or) workflow/activity doesn't exist then we would cancel
219
+ // RecordActivityHeartbeat sends a heartbeat for the currently executing activity.
220
+ // If the activity is either canceled or workflow/activity doesn't exist, then we would cancel
222
221
// the context with error context.Canceled.
223
222
//
224
223
// TODO: we don't have a way to distinguish between the two cases when context is canceled because
225
224
// context doesn't support overriding value of ctx.Error.
226
225
// TODO: Implement automatic heartbeating with cancellation through ctx.
227
226
//
228
- // details - the details that you provided here can be seen in the workflow when it receives TimeoutError, you
227
+ // details - The details that you provided here can be seen in the workflow when it receives TimeoutError. You
229
228
// can check error TimeoutType()/Details().
230
229
func RecordActivityHeartbeat (ctx context.Context , details ... interface {}) {
231
230
getActivityOutboundInterceptor (ctx ).RecordHeartbeat (ctx , details ... )
0 commit comments