You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* If this timeout is defined, the Activity must heartbeat before the timeout is reached.
174
174
* The Activity must **not** heartbeat in case this timeout is not defined.
175
175
*/
176
-
heartbeatTimeoutMs?: number;
176
+
readonlyheartbeatTimeoutMs?: number;
177
177
/**
178
178
* The {@link Context.heartbeat | details} from the last recorded heartbeat from the last attempt of this Activity.
179
179
*
180
180
* Use this to resume your Activity from a checkpoint.
181
181
*/
182
-
heartbeatDetails: any;
182
+
readonlyheartbeatDetails: any;
183
183
184
184
/**
185
185
* Task Queue the Activity is scheduled in.
186
186
*
187
187
* For Local Activities, this is set to the Workflow's Task Queue.
188
188
*/
189
-
taskQueue: string;
189
+
readonlytaskQueue: string;
190
190
}
191
191
192
192
/**
@@ -200,18 +200,34 @@ export interface Info {
200
200
* Call `Context.current()` from Activity code in order to get the current Activity's Context.
201
201
*/
202
202
exportclassContext{
203
+
/**
204
+
* Gets the context of the current Activity.
205
+
*
206
+
* Uses {@link https://nodejs.org/docs/latest-v14.x/api/async_hooks.html#async_hooks_class_asynclocalstorage | AsyncLocalStorage} under the hood to make it accessible in nested callbacks and promises.
207
+
*/
208
+
publicstaticcurrent(): Context{
209
+
conststore=asyncLocalStorage.getStore();
210
+
if(store===undefined){
211
+
thrownewError('Activity context not initialized');
212
+
}
213
+
returnstore;
214
+
}
215
+
203
216
/**
204
217
* Holds information about the current executing Activity.
205
218
*/
206
-
publicinfo: Info;
219
+
publicreadonlyinfo: Info;
220
+
207
221
/**
208
-
* Await this promise in an Activity to get notified of cancellation.
222
+
* A Promise that fails with a {@link CancelledFailure} when cancellation of this activity is requested. The promise
223
+
* is guaranteed to never successfully resolve. Await this promise in an Activity to get notified of cancellation.
209
224
*
210
-
* This promise will never resolve—it will only be rejected with a {@linkCancelledFailure}.
225
+
* Note that to get notified of cancellation, an activity must _also_ {@linkContext.heartbeat}.
* Uses {@link https://nodejs.org/docs/latest-v14.x/api/async_hooks.html#async_hooks_class_asynclocalstorage | AsyncLocalStorage} under the hood to make it accessible in nested callbacks and promises.
294
-
*/
295
-
publicstaticcurrent(): Context{
296
-
conststore=asyncLocalStorage.getStore();
297
-
if(store===undefined){
298
-
thrownewError('Activity context not initialized');
299
-
}
300
-
returnstore;
301
-
}
302
-
303
310
/**
304
311
* Helper function for sleeping in an Activity.
305
312
* @param ms Sleep duration: number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
306
313
* @returns A Promise that either resolves when `ms` is reached or rejects when the Activity is cancelled
0 commit comments