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
Copy file name to clipboardExpand all lines: packages/activity/src/index.ts
+69-23Lines changed: 69 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,42 @@
1
1
/**
2
-
* This library provides tools for authoring activities.
2
+
* This package's main export is {@link Context}. Get the current Activity's context with
3
+
* {@link Context.current | `Context.current()`}:
3
4
*
4
-
* Import this module from Activity code - must **not** be used in Workflows.
5
+
* ```ts
6
+
* import { Context } from '@temporalio/activity';
5
7
*
6
-
* Any function can be used as an Activity as long as its parameters and return value are serializable using a [`DataConverter`](../interfaces/worker.DataConverter.md).
8
+
* export async function myActivity() {
9
+
* const context = Context.current();
10
+
* }
11
+
* ```
12
+
*
13
+
* Any function can be used as an Activity as long as its parameters and return value are serializable using a
* Activities may be cancelled only if they [emit heartbeats](../classes/activity.Context.md#heartbeat).<br/>
10
-
* There are 2 ways to handle Activity cancellation:
11
-
* 1. await on [`Context.current().cancelled`](../classes/activity.Context.md#cancelled)
12
-
* 1. Pass the context's [abort signal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) at [`Context.current().cancellationSignal`](../classes/activity.Context.md#cancellationsignal) to a library that supports it
17
+
*
18
+
* Activities may be cancelled only if they {@link Context.heartbeat | emit heartbeats}.
19
+
*
20
+
* There are two ways to handle Activity cancellation:
21
+
* 1. await on {@link Context.cancelled | `Context.current().cancelled`} or
22
+
* {@link Context.sleep | `Context.current().sleep()`}, which each throw a
23
+
* {@link CancelledFailure}.
24
+
* 1. Pass the context's {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} at
25
+
* {@link Context.cancellationSignal | `Context.current().cancellationSignal`} to a library that
26
+
* supports it.
13
27
*
14
28
* ### Examples
15
29
*
16
-
* #### An Activity that fakes progress and can be cancelled
30
+
* #### An Activity that sends progress heartbeats and can be cancelled
* An `AbortSignal` which can be used to cancel requests on Activity cancellation.
177
+
* An {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that can be used to react to
178
+
* Activity cancellation.
144
179
*
145
-
* Typically used by the {@link https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal | fetch} and {@link https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options child_process} libraries but is supported by a few other libraries as well.
180
+
* Used by {@link https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal | fetch} to abort an
* Send a {@link https://docs.temporal.io/concepts/what-is-an-activity-heartbeat | heartbeat} from an Activity.
212
+
*
213
+
* If an Activity times out, then during the next retry, the last value of `details` is available at
214
+
* {@link Info.heartbeatDetails}. This acts as a periodic checkpoint mechanism for the progress of an Activity.
172
215
*
173
-
* If an Activity times out, the last value of details is included in the {@link ActivityFailure} delivered to a Workflow in the `cause` attribute which will be set to {@link TimeoutFailure}. Then the Workflow can pass the details to the next Activity invocation. This acts as a periodic checkpoint mechanism for the progress of an Activity.
216
+
* If an Activity times out on the final retry (relevant in cases in which {@link RetryPolicy.maximumAttempts} is
217
+
* set), the Activity function call in the Workflow code will throw an {@link ActivityFailure} with the `cause`
218
+
* attribute set to a {@link TimeoutFailure}, which has the last value of `details` available at
219
+
* {@link TimeoutFailure.lastHeartbeatDetails}.
174
220
*
175
-
* The Activity must heartbeat in order to receive cancellation.
221
+
* Activities must heartbeat in order to receive cancellation.
176
222
*/
177
223
publicheartbeat(details?: unknown): void{
178
224
this.heartbeatFn(details);
@@ -193,8 +239,8 @@ export class Context {
193
239
194
240
/**
195
241
* Helper function for sleeping in an Activity.
196
-
* @param ms sleep duration - {@link https://www.npmjs.com/package/ms | ms}formatted string or number of milliseconds
197
-
* @returnsa Promise that either resolves when deadline is reached or rejects when the Context is cancelled
242
+
* @param ms Sleep duration: an {@link https://www.npmjs.com/package/ms | ms}-formatted string or number of milliseconds
243
+
* @returnsA Promise that either resolves when `ms` is reached or rejects when the Activity is cancelled
Copy file name to clipboardExpand all lines: packages/client/src/index.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
/**
2
-
* Client for communicating with the Temporal service.
2
+
* Client for communicating with Temporal Server.
3
3
*
4
-
* Interact with workflows using {@link WorkflowClient} or call GRPC methods directly using {@link Connection.workflowService}.
4
+
* Most functionality is available through {@link WorkflowClient}, but you can also call gRPC methods directly using {@link Connection.workflowService} and {@link Connection.operatorService}.
Copy file name to clipboardExpand all lines: packages/common/src/converter/payload-converters.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -137,8 +137,9 @@ export class DefaultPayloadConverter extends CompositePayloadConverter {
137
137
}
138
138
139
139
/**
140
-
* The default {@link PayloadConverter} used by the SDK.
141
-
* Supports `Uint8Array` and JSON serializables (so if [`JSON.stringify(yourArgOrRetval)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) works, the default payload converter will work).
140
+
* The default {@link PayloadConverter} used by the SDK. Supports `Uint8Array` and JSON serializables (so if
0 commit comments