Skip to content

Commit

Permalink
[data-tables] Add options to submitTransaction (#32384)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR

`@azure/data-tables`

### Issues associated with this PR

Fixes #28624

### Describe the problem that is addressed by this PR

`submitTransaction` on `TableClient` didn't allow for passing
request-level options, such as an `AbortSignal` to cancel the request.
  • Loading branch information
xirzec authored Jan 2, 2025
1 parent 594557a commit 78dd272
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions sdk/tables/data-tables/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- Fix issue [#28624](https://github.com/Azure/azure-sdk-for-js/issues/28624) where request options were not available when submitting a transaction operation.

### Other Changes

Expand Down
2 changes: 1 addition & 1 deletion sdk/tables/data-tables/review/data-tables.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class TableClient {
listEntities<T extends object = Record<string, unknown>>(options?: ListTableEntitiesOptions): PagedAsyncIterableIterator<TableEntityResult<T>, TableEntityResultPage<T>>;
pipeline: Pipeline;
setAccessPolicy(tableAcl: SignedIdentifier[], options?: OperationOptions): Promise<SetAccessPolicyResponse>;
submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse>;
submitTransaction(actions: TransactionAction[], options?: OperationOptions): Promise<TableTransactionResponse>;
readonly tableName: string;
updateEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode, options?: UpdateTableEntityOptions): Promise<UpdateEntityResponse>;
upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode, options?: OperationOptions): Promise<UpsertEntityResponse>;
Expand Down
9 changes: 7 additions & 2 deletions sdk/tables/data-tables/src/TableClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,13 @@ export class TableClient {
* ```
*
* @param actions - tuple that contains the action to perform, and the entity to perform the action with
* @param options - Options for the request.
*/
public async submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse> {
public async submitTransaction(
actions: TransactionAction[],
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
options: OperationOptions = {},
): Promise<TableTransactionResponse> {
const partitionKey = actions[0][1].partitionKey;
const transactionId = Uuid.generateUuid();
const changesetId = Uuid.generateUuid();
Expand Down Expand Up @@ -888,7 +893,7 @@ export class TableClient {
}
}

return transactionClient.submitTransaction();
return transactionClient.submitTransaction(options);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions sdk/tables/data-tables/src/TableTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,11 @@ export class InternalTableTransaction {

/**
* Submits the operations in the transaction
* @param options - Options for the request.
*/
public async submitTransaction(): Promise<TableTransactionResponse> {
public async submitTransaction(
options: OperationOptions = {},
): Promise<TableTransactionResponse> {
await Promise.all(this.state.pendingOperations);
const body = getTransactionHttpRequestBody(
this.state.bodyParts,
Expand All @@ -285,14 +288,14 @@ export class InternalTableTransaction {

return tracingClient.withSpan(
"TableTransaction.submitTransaction",
{} as OperationOptions,
options,
async (updatedOptions) => {
const request = createPipelineRequest({
...updatedOptions,
url: this.url,
method: "POST",
body,
headers: createHttpHeaders(headers),
tracingOptions: updatedOptions.tracingOptions,
allowInsecureConnection: this.allowInsecureConnection,
});

Expand Down

0 comments on commit 78dd272

Please sign in to comment.