diff --git a/sdk/storage/storage-queue/BreakingChanges.md b/sdk/storage/storage-queue/BreakingChanges.md index 9027b8b32d24..5c2ba7dad05d 100644 --- a/sdk/storage/storage-queue/BreakingChanges.md +++ b/sdk/storage/storage-queue/BreakingChanges.md @@ -1,6 +1,12 @@ # Breaking Changes -2019.07 Version 12.0.0-preview.1 +### Coming Soon... 12.0.0-preview.2 + +- [Breaking] Aborter class is no longer exposed from the package. You are expected to use + the package [@azure/abort-controller](https://www.npmjs.com/package/@azure/abort-controller) to pass an abort signal to any of the async operations. + `AbortController.timeout()` can be utitlized as an abort signal. + +### 2019.07 Version 12.0.0-preview.1 - Client types are renamed from *URL to *Client. - QueueURL, MessagesURL, MessageIdURL, ServiceURL, StorageURL to QueueClient, MessagesClient, MessageIdClient, QueueServiceClient, StorageClient respectively. @@ -19,7 +25,7 @@ - `TokenCredential` has been renamed to `RawTokenCredential` to make way for the new `@azure/identity` library's `TokenCredential` interface. - Blob/Container member methods that manage leases are removed. A new type `LeaseClient` is added to manage leases. -2019.1 Version 10.1.0 +### 2019.1 Version 10.1.0 - Updated convenience layer methods enum type parameters into typescript union types, this will help to reduce bundle footprint. - `SASQueryParameters` is not going to be exported in browser bundle, and will be exported in Node.js runtime. diff --git a/sdk/storage/storage-queue/ChangeLog.md b/sdk/storage/storage-queue/ChangeLog.md index 43ec17c468ac..255e61b26f78 100644 --- a/sdk/storage/storage-queue/ChangeLog.md +++ b/sdk/storage/storage-queue/ChangeLog.md @@ -1,6 +1,12 @@ # Changelog -2019.07 Version 12.0.0-preview.1 +### Coming Soon... 12.0.0-preview.2 + +- [Breaking] Aborter class is no longer exposed from the package. You are expected to use + the package [@azure/abort-controller](https://www.npmjs.com/package/@azure/abort-controller) to pass an abort signal to any of the async operations. + `AbortController.timeout()` can be utitlized as an abort signal. + +### 2019.07 Version 12.0.0-preview.1 - [Breaking] Client types are renamed from *URL to *Client. - QueueURL, MessagesURL, MessageIdURL, ServiceURL, StorageURL to QueueClient, MessagesClient, MessageIdClient, QueueServiceClient, StorageClient respectively. @@ -31,7 +37,7 @@ For release notes and more information please visit https://aka.ms/azure-sdk-preview1-js -2019.1 Version 10.1.0 +### 2019.1 Version 10.1.0 - [Breaking] Updated convenience layer methods enum type parameters into typescript union types, this will help to reduce bundle footprint. - [Breaking] `SASQueryParameters` is not going to be exported in browser bundle, and will be exported in Node.js runtime. @@ -42,6 +48,6 @@ For release notes and more information please visit https://aka.ms/azure-sdk-pre - Fixed an issue that enqueue/dequeue/peek fail to work with some utf8 characters. - Exported HttpRequestBody type for who wants to implement a customized HTTP client. -2018.12 Version 10.0.0-preview +### 2018.12 Version 10.0.0-preview - Initial Release. API version 2018-03-28 supported. Please see the README for information on the new design. diff --git a/sdk/storage/storage-queue/package.json b/sdk/storage/storage-queue/package.json index eec4dbc22ce2..36c07f5ac4bb 100644 --- a/sdk/storage/storage-queue/package.json +++ b/sdk/storage/storage-queue/package.json @@ -75,6 +75,7 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js#readme", "sideEffects": false, "dependencies": { + "@azure/abort-controller": "1.0.0-preview.1", "@azure/core-http": "1.0.0-preview.2", "@azure/core-paging": "1.0.0-preview.1", "tslib": "^1.9.3" diff --git a/sdk/storage/storage-queue/recordings/browsers/aborter/recording_should_set_value_and_get_value_successfully.json b/sdk/storage/storage-queue/recordings/browsers/aborter/recording_should_set_value_and_get_value_successfully.json deleted file mode 100644 index b1fb235d4e0a..000000000000 --- a/sdk/storage/storage-queue/recordings/browsers/aborter/recording_should_set_value_and_get_value_successfully.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recordings": [], - "uniqueTestInfo": { - "queue": "queue156149651633209450" - } -} \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/node/aborter/recording_should_abort_after_parent_aborter_timeout.js b/sdk/storage/storage-queue/recordings/node/aborter/recording_should_abort_after_parent_aborter_timeout.js deleted file mode 100644 index 19ce438b77af..000000000000 --- a/sdk/storage/storage-queue/recordings/node/aborter/recording_should_abort_after_parent_aborter_timeout.js +++ /dev/null @@ -1,3 +0,0 @@ -let nock = require('nock'); - -module.exports.testInfo = {"queue":"queue156149546105200843"} diff --git a/sdk/storage/storage-queue/recordings/node/aborter/recording_should_set_value_and_get_value_successfully.js b/sdk/storage/storage-queue/recordings/node/aborter/recording_should_set_value_and_get_value_successfully.js deleted file mode 100644 index c4e0df7e7e15..000000000000 --- a/sdk/storage/storage-queue/recordings/node/aborter/recording_should_set_value_and_get_value_successfully.js +++ /dev/null @@ -1,3 +0,0 @@ -let nock = require('nock'); - -module.exports.testInfo = {"queue":"queue156149545862805136"} diff --git a/sdk/storage/storage-queue/src/Aborter.ts b/sdk/storage/storage-queue/src/Aborter.ts deleted file mode 100644 index f936e1923bd3..000000000000 --- a/sdk/storage/storage-queue/src/Aborter.ts +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { AbortSignalLike, isNode } from "@azure/core-http"; - -/** - * An aborter instance implements AbortSignal interface, can abort HTTP requests. - * - * - Call Aborter.none to create a new Aborter instance without timeout. - * - Call Aborter.timeout() to create a new Aborter instance with timeout. - * - * For an existing instance aborter: - * - Call aborter.withTimeout() to create and return a child Aborter instance with timeout. - * - Call aborter.withValue(key, value) to create and return a child Aborter instance with key/value pair. - * - Call aborter.abort() to abort current instance and all children instances. - * - Call aborter.getValue(key) to search and get value with corresponding key from current aborter to all parents. - * - * @export - * @class Aborter - * @implements {AbortSignalLike} - */ - -export class Aborter implements AbortSignalLike { - /** - * Status of whether aborted or not. - * - * @readonly - * @type {boolean} - * @memberof Aborter - */ - public get aborted(): boolean { - return this._aborted; - } - - /** - * Creates a new Aborter instance without timeout. - * - * @readonly - * @static - * @type {Aborter} - * @memberof Aborter - */ - public static get none(): Aborter { - return new Aborter(undefined, 0); - } - - /** - * Creates a new Aborter instance with timeout in milliseconds. - * Set parameter timeout to 0 will not create a timer. - * - * @static - * @param {number} {timeout} in milliseconds - * @returns {Aborter} - * @memberof Aborter - */ - public static timeout(timeout: number): Aborter { - return new Aborter(undefined, timeout); - } - - /** - * onabort event listener. - * - * @memberof Aborter - */ - public onabort?: (ev?: Event) => any; - - // tslint:disable-next-line:variable-name - private _aborted: boolean = false; - private timer?: any; - private readonly parent?: Aborter; - private readonly children: Aborter[] = []; // When child object calls dispose(), remove child from here - private readonly abortEventListeners: Array<(this: AbortSignalLike, ev?: any) => any> = []; - // Pipeline proxies need to use "abortSignal as Aborter" in order to access non AbortSignalLike methods - // immutable primitive types - private readonly key?: string; - private readonly value?: string | number | boolean | null; - // private disposed: boolean = false; - - /** - * Private constructor for internal usage, creates an instance of Aborter. - * - * @param {Aborter} [parent] Optional. Parent aborter. - * @param {number} [timeout=0] Optional. Timeout before abort in millisecond, 0 means no timeout. - * @param {string} [key] Optional. Immutable key in string. - * @param {(string | number | boolean | null)} [value] Optional. Immutable value. - * @memberof Aborter - */ - private constructor( - parent?: Aborter, - timeout: number = 0, - key?: string, - value?: string | number | boolean | null - ) { - this.parent = parent; - this.key = key; - this.value = value; - - if (timeout > 0) { - this.timer = setTimeout(() => { - this.abort.call(this); - }, timeout); - - // When called, the active Timeout object will not require the Node.js event loop - // to remain active. If there is no other activity keeping the event loop running, - // the process may exit before the Timeout object's callback is invoked. - if (this.timer && isNode) { - this.timer!.unref(); - } - } - } - - /** - * Create and return a new Aborter instance, which will be appended as a child node of current Aborter. - * Current Aborter instance becomes father node of the new instance. When current or father Aborter node - * triggers timeout event, all children nodes abort event will be triggered too. - * - * When timeout parameter (in millisecond) is larger than 0, the abort event will be triggered when timeout. - * Otherwise, call abort() method to manually abort. - * - * @param {number} {timeout} Timeout in millisecond. - * @returns {Aborter} The new Aborter instance created. - * @memberof Aborter - */ - public withTimeout(timeout: number): Aborter { - const childCancelContext = new Aborter(this, timeout); - this.children.push(childCancelContext); - return childCancelContext; - } - - /** - * Create and return a new Aborter instance, which will be appended as a child node of current Aborter. - * Current Aborter instance becomes father node of the new instance. When current or father Aborter node - * triggers timeout event, all children nodes abort event will be triggered too. - * - * Immutable key value pair will be set into the new created Aborter instance. - * Call getValue() to find out latest value with corresponding key in the chain of - * [current node] -> [parent node] and [grand parent node].... - * - * @param {string} key - * @param {(string | number | boolean | null)} [value] - * @returns {Aborter} - * @memberof Aborter - */ - public withValue(key: string, value?: string | number | boolean | null): Aborter { - const childCancelContext = new Aborter(this, 0, key, value); - this.children.push(childCancelContext); - return childCancelContext; - } - - /** - * Find out latest value with corresponding key in the chain of - * [current node] -> [parent node] -> [grand parent node] -> ... -> [root node]. - * - * If key is not found, undefined will be returned. - * - * @param {string} key - * @returns {(string | number | boolean | null | undefined)} - * @memberof Aborter - */ - public getValue(key: string): string | number | boolean | null | undefined { - for (let parent: Aborter | undefined = this; parent; parent = parent.parent) { - if (parent.key === key) { - return parent.value; - } - } - return undefined; - } - - /** - * Trigger abort event immediately, the onabort and all abort event listeners will be triggered. - * Will try to trigger abort event for all children Aborter nodes. - * - * - If there is a timeout, the timer will be cancelled. - * - If aborted is true, nothing will happen. - * - * @returns - * @memberof Aborter - */ - public abort() { - if (this.aborted) { - return; - } - this.cancelTimer(); - - if (this.onabort) { - this.onabort.call(this); - } - - this.abortEventListeners.forEach((listener) => { - listener.call(this, undefined); - }); - - this.children.forEach((child) => child.cancelByParent()); - - this._aborted = true; - } - - // public dispose() { - // if (this.disposed || this.aborted) { - // return; - // } - - // this.cancelTimer(); - - // // (parent)A <- B <- C(child), if B disposes, when A abort, C will not abort - // if (this.parent) { - // const index = this.parent.children.indexOf(this); - // if (index > -1) { - // this.parent.children.splice(index, 1); - // } - // } - - // this.disposed = true; - // } - - /** - * Added new "abort" event listener, only support "abort" event. - * - * @param {"abort"} _type Only support "abort" event - * @param {(this: AbortSignalLike, ev: any) => any} listener - * @memberof Aborter - */ - public addEventListener( - // tslint:disable-next-line:variable-name - _type: "abort", - listener: (this: AbortSignalLike, ev: any) => any - ): void { - this.abortEventListeners.push(listener); - } - - /** - * Remove "abort" event listener, only support "abort" event. - * - * @param {"abort"} _type Only support "abort" event - * @param {(this: AbortSignalLike, ev: any) => any} listener - * @memberof Aborter - */ - public removeEventListener( - // tslint:disable-next-line:variable-name - _type: "abort", - listener: (this: AbortSignalLike, ev: any) => any - ): void { - const index = this.abortEventListeners.indexOf(listener); - if (index > -1) { - this.abortEventListeners.splice(index, 1); - } - } - - private cancelByParent() { - // if (!this.disposed) { - this.abort(); - // } - } - - private cancelTimer() { - if (this.timer) { - clearTimeout(this.timer); - } - } -} diff --git a/sdk/storage/storage-queue/src/MessageIdClient.ts b/sdk/storage/storage-queue/src/MessageIdClient.ts index c4364a59e2e8..25b41b4ea780 100644 --- a/sdk/storage/storage-queue/src/MessageIdClient.ts +++ b/sdk/storage/storage-queue/src/MessageIdClient.ts @@ -3,7 +3,7 @@ import { TokenCredential, isTokenCredential, isNode } from "@azure/core-http"; import * as Models from "./generated/lib/models"; -import { Aborter } from "./Aborter"; +import { AbortSignalLike, AbortSignal } from "@azure/abort-controller"; import { MessageId } from "./generated/lib/operations"; import { newPipeline, NewPipelineOptions, Pipeline } from "./Pipeline"; import { SharedKeyCredential } from "./credentials/SharedKeyCredential"; @@ -19,14 +19,13 @@ import { extractConnectionStringParts } from "./utils/utils.common"; */ export interface MessageIdDeleteOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -37,14 +36,13 @@ export interface MessageIdDeleteOptions { */ export interface MessageIdUpdateOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -199,7 +197,7 @@ export class MessageIdClient extends StorageClient { popReceipt: string, options: MessageIdDeleteOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.messageIdContext.deleteMethod(popReceipt, { abortSignal: aborter }); @@ -228,7 +226,7 @@ export class MessageIdClient extends StorageClient { visibilityTimeout?: number, options: MessageIdUpdateOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.messageIdContext.update( { messageText: message diff --git a/sdk/storage/storage-queue/src/MessagesClient.ts b/sdk/storage/storage-queue/src/MessagesClient.ts index 10654cb0cae7..8f8d85d22bf1 100644 --- a/sdk/storage/storage-queue/src/MessagesClient.ts +++ b/sdk/storage/storage-queue/src/MessagesClient.ts @@ -3,7 +3,7 @@ import { HttpResponse, TokenCredential, isTokenCredential, isNode } from "@azure/core-http"; import * as Models from "./generated/lib/models"; -import { Aborter } from "./Aborter"; +import { AbortSignalLike, AbortSignal } from "@azure/abort-controller"; import { Messages } from "./generated/lib/operations"; import { newPipeline, NewPipelineOptions, Pipeline } from "./Pipeline"; import { StorageClient } from "./StorageClient"; @@ -20,14 +20,13 @@ import { AnonymousCredential } from "./credentials/AnonymousCredential"; */ export interface MessagesClearOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -37,7 +36,7 @@ export interface MessagesClearOptions { * @interface MessagesEnqueueOptions * @extends {Models.MessagesEnqueueOptionalParams} */ -export interface MessagesEnqueueOptions extends Models.MessagesEnqueueOptionalParams {} +export interface MessagesEnqueueOptions extends Models.MessagesEnqueueOptionalParams { } /** * Options to configure Messages - Dequeue operation @@ -46,7 +45,7 @@ export interface MessagesEnqueueOptions extends Models.MessagesEnqueueOptionalPa * @interface MessagesDequeueOptions * @extends {Models.MessagesDequeueOptionalParams} */ -export interface MessagesDequeueOptions extends Models.MessagesDequeueOptionalParams {} +export interface MessagesDequeueOptions extends Models.MessagesDequeueOptionalParams { } /** * Options to configure Messages - Peek operation @@ -55,7 +54,7 @@ export interface MessagesDequeueOptions extends Models.MessagesDequeueOptionalPa * @interface MessagesPeekOptions * @extends {Models.MessagesPeekOptionalParams} */ -export interface MessagesPeekOptions extends Models.MessagesPeekOptionalParams {} +export interface MessagesPeekOptions extends Models.MessagesPeekOptionalParams { } export declare type MessagesEnqueueResponse = { /** @@ -84,68 +83,68 @@ export declare type MessagesEnqueueResponse = { */ timeNextVisible: Date; } & Models.MessagesEnqueueHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: Models.MessagesEnqueueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: Models.EnqueuedMessage[]; - }; + parsedHeaders: Models.MessagesEnqueueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: Models.EnqueuedMessage[]; }; +}; export declare type MessagesDequeueResponse = { dequeuedMessageItems: Models.DequeuedMessageItem[]; } & Models.MessagesDequeueHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: Models.MessagesDequeueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: Models.DequeuedMessageItem[]; - }; + parsedHeaders: Models.MessagesDequeueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: Models.DequeuedMessageItem[]; }; +}; export declare type MessagesPeekResponse = { peekedMessageItems: Models.PeekedMessageItem[]; } & Models.MessagesPeekHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: Models.MessagesPeekHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: Models.PeekedMessageItem[]; - }; + parsedHeaders: Models.MessagesPeekHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: Models.PeekedMessageItem[]; }; +}; /** * A MessagesClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages. @@ -275,7 +274,7 @@ export class MessagesClient extends StorageClient { * @memberof MessagesClient */ public async clear(options: MessagesClearOptions = {}): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.messagesContext.clear({ abortSignal: aborter }); @@ -306,7 +305,7 @@ export class MessagesClient extends StorageClient { messageText: string, options: MessagesEnqueueOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; const response = await this.messagesContext.enqueue( { messageText: messageText @@ -335,14 +334,12 @@ export class MessagesClient extends StorageClient { * Dequeue retrieves one or more messages from the front of the queue. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-messages * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {MessagesDequeueOptionals} [options] Options to Messages dequeue operation. * @returns {Promise} Response data for the Messages dequeue operation. * @memberof MessagesClient */ public async dequeue(options: MessagesDequeueOptions = {}): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; const response = await this.messagesContext.dequeue({ abortSignal: aborter, ...options @@ -368,14 +365,12 @@ export class MessagesClient extends StorageClient { * Peek retrieves one or more messages from the front of the queue but does not alter the visibility of the message. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/peek-messages * - * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), - * goto documents of Aborter for more examples about request cancellation * @param {MessagesPeekOptions} [options] Options to Messages peek operation. * @returns {Promise} Response data for the Messages peek operation. * @memberof MessagesClient */ public async peek(options: MessagesPeekOptions = {}): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; const response = await this.messagesContext.peek({ abortSignal: aborter, ...options diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index 8de5aea10f0b..187bf874187b 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -3,7 +3,7 @@ import { HttpResponse, TokenCredential, isTokenCredential, isNode } from "@azure/core-http"; import * as Models from "./generated/lib/models"; -import { Aborter } from "./Aborter"; +import { AbortSignalLike, AbortSignal } from "@azure/abort-controller"; import { Queue } from "./generated/lib/operations"; import { Metadata } from "./models"; import { newPipeline, NewPipelineOptions, Pipeline } from "./Pipeline"; @@ -25,14 +25,13 @@ import { AnonymousCredential } from "./credentials/AnonymousCredential"; */ export interface QueueCreateOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; /** * A collection of key-value string pair to associate with the queue object. * The keys need to be lower-case. @@ -51,14 +50,13 @@ export interface QueueCreateOptions { */ export interface QueueGetPropertiesOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -69,14 +67,13 @@ export interface QueueGetPropertiesOptions { */ export interface QueueDeleteOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -87,14 +84,13 @@ export interface QueueDeleteOptions { */ export interface QueueGetAccessPolicyOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -105,14 +101,13 @@ export interface QueueGetAccessPolicyOptions { */ export interface QueueSetAccessPolicyOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -123,14 +118,13 @@ export interface QueueSetAccessPolicyOptions { */ export interface QueueSetMetadataOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -167,24 +161,24 @@ export interface SignedIdentifier { export declare type QueueGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & Models.QueueGetAccessPolicyHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: Models.QueueGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: Models.SignedIdentifier[]; - }; + parsedHeaders: Models.QueueGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: Models.SignedIdentifier[]; }; +}; /** * A QueueClient represents a URL to the Azure Storage queue. @@ -314,7 +308,7 @@ export class QueueClient extends StorageClient { * @memberof QueueClient */ public async create(options: QueueCreateOptions = {}): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.queueContext.create({ ...options, abortSignal: aborter @@ -341,7 +335,7 @@ export class QueueClient extends StorageClient { public async getProperties( options: QueueGetPropertiesOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.queueContext.getProperties({ abortSignal: aborter }); @@ -356,7 +350,7 @@ export class QueueClient extends StorageClient { * @memberof QueueClient */ public async delete(options: QueueDeleteOptions = {}): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.queueContext.deleteMethod({ abortSignal: aborter }); @@ -378,7 +372,7 @@ export class QueueClient extends StorageClient { metadata?: Metadata, options: QueueSetMetadataOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.queueContext.setMetadata({ abortSignal: aborter, metadata @@ -400,7 +394,7 @@ export class QueueClient extends StorageClient { public async getAccessPolicy( options: QueueGetAccessPolicyOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; const response = await this.queueContext.getAccessPolicy({ abortSignal: aborter }); @@ -442,7 +436,7 @@ export class QueueClient extends StorageClient { queueAcl?: SignedIdentifier[], options: QueueSetAccessPolicyOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; const acl: Models.SignedIdentifier[] = []; for (const identifier of queueAcl || []) { acl.push({ diff --git a/sdk/storage/storage-queue/src/QueueServiceClient.ts b/sdk/storage/storage-queue/src/QueueServiceClient.ts index 2f1bd122b441..36f9a425dda5 100644 --- a/sdk/storage/storage-queue/src/QueueServiceClient.ts +++ b/sdk/storage/storage-queue/src/QueueServiceClient.ts @@ -3,7 +3,7 @@ import { TokenCredential, isTokenCredential, isNode } from "@azure/core-http"; import * as Models from "./generated/lib/models"; -import { Aborter } from "./Aborter"; +import { AbortSignalLike, AbortSignal } from "@azure/abort-controller"; import { ListQueuesIncludeType } from "./generated/lib/models/index"; import { Service } from "./generated/lib/operations"; import { newPipeline, NewPipelineOptions, Pipeline } from "./Pipeline"; @@ -23,14 +23,13 @@ import { AnonymousCredential } from "./credentials/AnonymousCredential"; */ export interface ServiceGetPropertiesOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -41,14 +40,13 @@ export interface ServiceGetPropertiesOptions { */ export interface ServiceSetPropertiesOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -59,14 +57,13 @@ export interface ServiceSetPropertiesOptions { */ export interface ServiceGetStatisticsOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof AppendBlobCreateOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; } /** @@ -76,14 +73,13 @@ export interface ServiceGetStatisticsOptions { */ interface ServiceListQueuesSegmentOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof ServiceListQueuesSegmentOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; /** * @member {string} [prefix] Filters the results to return only queues * whose name begins with the specified prefix. @@ -115,14 +111,13 @@ interface ServiceListQueuesSegmentOptions { */ export interface ServiceListQueuesOptions { /** - * Aborter instance to cancel request. It can be created with Aborter.none - * or Aborter.timeout(). Go to documents of {@link Aborter} for more examples - * about request cancellation. + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. * - * @type {Aborter} + * @type {AbortSignalLike} * @memberof ServiceListQueuesOptions */ - abortSignal?: Aborter; + abortSignal?: AbortSignalLike; /** * @member {string} [prefix] Filters the results to return only queues * whose name begins with the specified prefix. @@ -263,7 +258,7 @@ export class QueueServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.serviceContext.getProperties({ abortSignal: aborter }); @@ -283,7 +278,7 @@ export class QueueServiceClient extends StorageClient { properties: Models.StorageServiceProperties, options: ServiceGetPropertiesOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.serviceContext.setProperties(properties, { abortSignal: aborter }); @@ -302,7 +297,7 @@ export class QueueServiceClient extends StorageClient { public async getStatistics( options: ServiceGetStatisticsOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.serviceContext.getStatistics({ abortSignal: aborter }); @@ -327,7 +322,7 @@ export class QueueServiceClient extends StorageClient { marker?: string, options: ServiceListQueuesSegmentOptions = {} ): Promise { - const aborter = options.abortSignal || Aborter.none; + const aborter = options.abortSignal || AbortSignal.none; return this.serviceContext.listQueuesSegment({ abortSignal: aborter, marker, diff --git a/sdk/storage/storage-queue/src/index.browser.ts b/sdk/storage/storage-queue/src/index.browser.ts index c1347d36766b..332aa8fd3326 100644 --- a/sdk/storage/storage-queue/src/index.browser.ts +++ b/sdk/storage/storage-queue/src/index.browser.ts @@ -5,7 +5,6 @@ import { RestError } from "@azure/core-http"; import * as Models from "../src/generated/lib/models"; -export * from "./Aborter"; export * from "./credentials/AnonymousCredential"; export * from "./credentials/Credential"; export * from "./credentials/RawTokenCredential"; diff --git a/sdk/storage/storage-queue/src/index.ts b/sdk/storage/storage-queue/src/index.ts index e3c623f117d3..074e55fd1802 100644 --- a/sdk/storage/storage-queue/src/index.ts +++ b/sdk/storage/storage-queue/src/index.ts @@ -5,7 +5,6 @@ import { RestError } from "@azure/core-http"; import * as Models from "../src/generated/lib/models"; -export * from "./Aborter"; export * from "./AccountSASPermissions"; export * from "./AccountSASResourceTypes"; export * from "./AccountSASServices"; diff --git a/sdk/storage/storage-queue/test/aborter.spec.ts b/sdk/storage/storage-queue/test/aborter.spec.ts index f55038123b1a..65a975a61111 100644 --- a/sdk/storage/storage-queue/test/aborter.spec.ts +++ b/sdk/storage/storage-queue/test/aborter.spec.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { Aborter } from "../src/Aborter"; +import { AbortController } from "@azure/abort-controller"; import { QueueClient } from "../src/QueueClient"; import { getQSU } from "./utils"; @@ -25,11 +25,6 @@ describe("Aborter", () => { recorder.stop(); }); - it("should set value and get value successfully", async () => { - const aborter = Aborter.none.withValue("mykey", "myvalue"); - assert.deepStrictEqual(aborter.getValue("mykey"), "myvalue"); - }); - it("should not abort after calling abort()", async () => { const cResp = await queueClient.create(); assert.ok(cResp.date); @@ -37,8 +32,8 @@ describe("Aborter", () => { }); it("should abort when calling abort() before request finishes", async () => { - const aborter = Aborter.none; - const response = queueClient.create({ abortSignal: aborter }); + const aborter = new AbortController(); + const response = queueClient.create({ abortSignal: aborter.signal }); aborter.abort(); try { await response; @@ -47,35 +42,26 @@ describe("Aborter", () => { }); it("should not abort when calling abort() after request finishes", async () => { - const aborter = Aborter.none; - await queueClient.create({ abortSignal: aborter }); + const aborter = new AbortController(); + await queueClient.create({ abortSignal: aborter.signal }); aborter.abort(); await queueClient.delete(); }); it("should abort after aborter timeout", async () => { try { - await queueClient.create({ abortSignal: Aborter.timeout(1) }); + await queueClient.create({ abortSignal: AbortController.timeout(1) }); assert.fail(); } catch (err) {} }); it("should abort after parent aborter calls abort()", async () => { try { - const aborter = Aborter.none; - const response = queueClient.create({ abortSignal: aborter.withTimeout(10 * 60 * 1000) }); + const aborter = new AbortController(); + const response = queueClient.create({ abortSignal: AbortController.timeout(10 * 60 * 1000) }); aborter.abort(); await response; assert.fail(); } catch (err) {} }); - - it("should abort after parent aborter timeout", async () => { - try { - const aborter = Aborter.timeout(1); - const response = queueClient.create({ abortSignal: aborter.withTimeout(10 * 60 * 1000) }); - await response; - assert.fail(); - } catch (err) {} - }); });