Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[storage][stg74] queue improvement #11258

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/review/storage-queue.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class QueueClient extends StorageClient {
sendMessage(messageText: string, options?: QueueSendMessageOptions): Promise<QueueSendMessageResponse>;
setAccessPolicy(queueAcl?: SignedIdentifier[], options?: QueueSetAccessPolicyOptions): Promise<QueueSetAccessPolicyResponse>;
setMetadata(metadata?: Metadata, options?: QueueSetMetadataOptions): Promise<QueueSetMetadataResponse>;
updateMessage(messageId: string, popReceipt: string, message: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise<QueueUpdateMessageResponse>;
updateMessage(messageId: string, popReceipt: string, message?: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise<QueueUpdateMessageResponse>;
}

// @public
Expand Down
11 changes: 7 additions & 4 deletions sdk/storage/storage-queue/src/QueueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,18 +1271,21 @@ export class QueueClient extends StorageClient {
public async updateMessage(
messageId: string,
popReceipt: string,
message: string,
message?: string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add what's the by design behavior when message is undefined into method's comments.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments "If this parameter is undefined, then the content of the message won't be updated."

visibilityTimeout?: number,
options: QueueUpdateMessageOptions = {}
): Promise<QueueUpdateMessageResponse> {
const { span, spanOptions } = createSpan("QueueClient-updateMessage", options.tracingOptions);
let queueMessage = undefined;
if (message) {
queueMessage = { messageText: message };
}

try {
return await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
abortSignal: options.abortSignal,
spanOptions,
queueMessage: {
messageText: message
}
queueMessage
});
} catch (e) {
span.setStatus({
Expand Down
9 changes: 9 additions & 0 deletions sdk/storage/storage-queue/test/messageidclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,13 @@ describe("QueueClient messageId methods", () => {
);
assert.equal(newClient.name, queueName, "Queue name is not the same as the one provided.");
});

it("update visibility timeout only preserve content", async () => {
const message = "foo";
const enqueueRes = await queueClient.sendMessage(message, { visibilityTimeout: 10 });
await queueClient.updateMessage(enqueueRes.messageId, enqueueRes.popReceipt);
const receiveMessage = (await queueClient.receiveMessages()).receivedMessageItems[0];
assert.equal(enqueueRes.messageId, receiveMessage.messageId);
assert.equal(message, receiveMessage.messageText);
});
});