-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[@azure/eventgrid] Fix the Push Issue with the PublishCloudEvents API #26307
[@azure/eventgrid] Fix the Push Issue with the PublishCloudEvents API #26307
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I added some minor feedback
}); | ||
|
||
afterEach(async function () { | ||
// Clear any messages that may be available in the topic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to clear in both beforeEach
and afterEach
? if yes maybe extract duplicate code to a helper function
while (true) { | ||
const receivedResult: ReceiveResult<ApiManagementGatewayCreatedEventData> = | ||
await client.receiveCloudEvents(topicName, eventSubscripionName); | ||
if (!receivedResult || receivedResult.value.length === 0) break; | ||
const lockToken = receivedResult.value[0].brokerProperties.lockToken; | ||
await client.acknowledgeCloudEvents([lockToken], topicName, eventSubscripionName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one way to avoid the constant condition:
while (true) { | |
const receivedResult: ReceiveResult<ApiManagementGatewayCreatedEventData> = | |
await client.receiveCloudEvents(topicName, eventSubscripionName); | |
if (!receivedResult || receivedResult.value.length === 0) break; | |
const lockToken = receivedResult.value[0].brokerProperties.lockToken; | |
await client.acknowledgeCloudEvents([lockToken], topicName, eventSubscripionName); | |
} | |
let receivedResult: ReceiveResult<ApiManagementGatewayCreatedEventData> = | |
await client.receiveCloudEvents(topicName, eventSubscripionName); | |
while (receivedResult && receivedResult.value.length > 0) { | |
const lockToken = receivedResult.value[0].brokerProperties.lockToken; | |
await client.acknowledgeCloudEvents([lockToken], topicName, eventSubscripionName); | |
receivedResult = await client.receiveCloudEvents(topicName, eventSubscripionName); | |
} |
) ### Packages impacted by this PR @Azure/eventgrid ### Issues associated with this PR NA ### Describe the problem that is addressed by this PR 1. The EventGrid Service team has made changes to their [CADL specification](https://github.com/Azure/azure-rest-api-specs/tree/main/specification/eventgrid/Azure.Messaging.EventGrid). This PR regenerates the SDK using the latest CADL specification. 2. Important changes in this PR: i. A new API `renewCloudEventLocks` has been added. ii. In the ` publishCloudEvent` API, a new option `binaryMode` has been added. This enables the users to send in the binary encoded event. iii. There are some other minor changes and some breaking changes also in this PR. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? One of the design decisions is around the `binaryMode`. Currently, the API accepts only binary encoded data for this API. If there is a requirement in the future that the user prefers that the encoding be done by the SDK, we could consider it in future, ### Are there test cases added in this PR? _(If not, why?)_ Yes. New test cases have been added to test the `binaryMode` and the new `renewCloudEventLocks` API. ### Provide a list of related PRs _(if any)_ 1. #26307 2. #25906 ### Checklists - [X] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [X] Added a changelog (if necessary) @xirzec Please review and approve the PR & API Views. ## API View to approve 1. [Link 1](https://apiview.dev/Assemblies/Review/0ead6d0c15c64cd7a007a11f514cfc4c/b94b6c83619f4dcfb04e476365bf7e19?diffRevisionId=fb754e995af24441901461c1c6ada906&doc=False&diffOnly=True) (This compares this Beta 3 version with Beta 2 version which gives you a clear view of the changes) 2. [Link 2](https://apiview.dev/Assemblies/Review/b6a1a4040a1f46528f095df8589bfa3e/80e3111615cc47f49b25a4f16d9e1322?diffRevisionId=20bf158c9f2341eba08c706d55a0aa4c&doc=False&diffOnly=True) (This is generated automatically by the PR Bot wgich compares the Beta 3 version with latest GA which is not correct. But, in order to release the SDK, we need the approval for the same. So, kindly review the Link 1 and approve both). Thanks
Packages impacted by this PR
@azure/eventgrid
Issues associated with this PR
N/A
Describe the problem that is addressed by this PR
In the EventGrid V2 Beta Version, we have an API called
publishCloudEvents
. In this API, each of the event (from parameters) must be converted and pushed to theeventsWireModel
array. Now, while pushing it, a wrong method is called on the array. Instead of callingpush
method,concat
method is called which causes the array to be empty and causes issue. This PR changes the method topush
.Integration Test Cases have been added for each API in EventGrid Client. The associated recordings have been added to the PR.
Note: Since this is a Bug Fix release, I have updated the Version from
4.13.0-beta.1
to4.13.0-beta.2
.What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?
The design is simple and straightforward. No special concern.
Are there test cases added in this PR? (If not, why?)
Yes. The test cases have been added for each API of the EventGrid client.
Provide a list of related PRs (if any)
N/A
Command used to generate this PR:**(Applicable only to SDK release request PRs)
N/A
Checklists
@ellismg @xirzec @jeremymeng Please review and approve the PR.
@lmazuel FYI....