guan404ming commented on code in PR #75392:
URL: https://github.com/apache/airflow/pull/75392#discussion_r4617035987
##########
ts-sdk/src/sdk/client.ts:
##########
@@ -84,16 +85,38 @@ export interface TaskClient {
* const data = await client.getXCom<{ count: number }>({ key: "result" });
* // data is { count: number } | null
* ```
+ *
+ * @throws `TypeError` when `key`, `dagId`, `taskId` or `runId` is not a
string, or `mapIndex` is not a number or `null`.
+ * @throws `RangeError` when `key`, `dagId`, `taskId` or `runId` is empty,
or `mapIndex` is not an integer.
*/
getXCom<T = unknown>(opts: GetXComOpts): Promise<T | null>;
/**
* Push an XCom value.
*
- * Target fields default to the current task's context.
+ * Target fields default to the current task's context; see
+ * {@link SetXComOpts} for how `mapIndex` defaults.
+ *
+ * @throws `TypeError` when `key`, `dagId`, `taskId` or `runId` is not a
string, or `mapIndex` is not a number or `null`.
+ * @throws `RangeError` when `key`, `dagId`, `taskId` or `runId` is empty,
or `mapIndex` is not an integer.
*/
setXCom(opts: SetXComOpts): Promise<void>;
+ /**
+ * Delete an XCom value.
+ *
+ * Target fields default to the current task's context; see
+ * {@link DeleteXComOpts} for how `mapIndex` defaults.
+ *
+ * Resolves whether or not anything was deleted. A key with no stored value
+ * and a target task that does not exist both succeed, so a resolved promise
+ * is not proof that an XCom was removed.
+ *
+ * @throws `TypeError` when `key` is not a string, or `mapIndex` is not a
number or `null`.
Review Comment:
The `@throws` lines skip `dagId`, `taskId` and `runId`, which
`resolveXComTarget` also checks for `deleteXCom`
##########
ts-sdk/src/sdk/client.ts:
##########
@@ -84,16 +85,38 @@ export interface TaskClient {
* const data = await client.getXCom<{ count: number }>({ key: "result" });
* // data is { count: number } | null
* ```
+ *
+ * @throws `TypeError` when `key`, `dagId`, `taskId` or `runId` is not a
string, or `mapIndex` is not a number or `null`.
+ * @throws `RangeError` when `key`, `dagId`, `taskId` or `runId` is empty,
or `mapIndex` is not an integer.
*/
getXCom<T = unknown>(opts: GetXComOpts): Promise<T | null>;
/**
* Push an XCom value.
*
- * Target fields default to the current task's context.
+ * Target fields default to the current task's context; see
+ * {@link SetXComOpts} for how `mapIndex` defaults.
+ *
+ * @throws `TypeError` when `key`, `dagId`, `taskId` or `runId` is not a
string, or `mapIndex` is not a number or `null`.
+ * @throws `RangeError` when `key`, `dagId`, `taskId` or `runId` is empty,
or `mapIndex` is not an integer.
*/
setXCom(opts: SetXComOpts): Promise<void>;
+ /**
+ * Delete an XCom value.
+ *
+ * Target fields default to the current task's context; see
+ * {@link DeleteXComOpts} for how `mapIndex` defaults.
+ *
+ * Resolves whether or not anything was deleted. A key with no stored value
+ * and a target task that does not exist both succeed, so a resolved promise
+ * is not proof that an XCom was removed.
+ *
+ * @throws `TypeError` when `key` is not a string, or `mapIndex` is not a
number or `null`.
+ * @throws `RangeError` when `key` is empty, or `mapIndex` is not an integer.
+ */
+ deleteXCom(opts: DeleteXComOpts): Promise<void>;
Review Comment:
Could we say in the PR body whether Go and Java get a public delete too
##########
ts-sdk/src/sdk/client-types.ts:
##########
@@ -50,6 +58,23 @@ export interface SetXComOpts {
mapIndex?: number | null;
}
+/**
+ * Options for deleting an XCom value.
+ *
+ * `dagId`, `taskId`, and `runId` default to the running task's context.
+ *
+ * `mapIndex` defaults to the running task's own map index when the target is
+ * the running task, and to the unmapped value for any other task or run. Pass
+ * a number to pick one mapped instance, or `null` for the unmapped one.
+ */
+export interface DeleteXComOpts {
Review Comment:
nit: `XComTargetOpts` and the test `XComOpts` alias match this type, so both
could reuse it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]