-
Notifications
You must be signed in to change notification settings - Fork 371
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
feat(fcm): Add sendEach
and sendEachForMulticast
for FCM batch send
#2138
Conversation
1. Deprecate sendAll and sendMulticast 2. Add dummy implementation for sendEach and sendEachForMulticast to avoid errors reported by api-extractor
`sendEach` vs `sendAll` 1. `sendEach` sends one HTTP request to V1 Send endpoint for each message in the array. `sendAll` sends only one HTTP request to V1 Batch Send endpoint to send all messages in the array. 2. `sendEach` calls `Promise.allSettled` to wait for all `httpClient.send` calls to complete and construct a `BatchResponse`. An `httpClient.send` call to V1 Send endpoint either completes with a success or throws an error. So if an error is thrown out, the error will be caught in `sendEach` and turned into a `SendResponse` with an error. Therefore, unlike `sendAll`, `sendEach` does not always throw an error for a total failure. It can also return a `BatchResponse` with only errors in it. `sendEachForMulticast` calls `sendEach` under the hood.
sendEach
and sendEachForMulticast
for FCM batch sendsendEach
and sendEachForMulticast
for FCM batch send
Thank you @Doris-Ge . Let's get the docs reviewed by @egilmorez before we merge this. |
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.
LG with one optional nit, thanks!
src/messaging/messaging.ts
Outdated
* | ||
* The responses list obtained from the return value corresponds to the order of `messages`. | ||
* An error from this method or a `BatchResponse` with all failures indicates a total failure | ||
* -- i.e. none of the messages in the list could be sent. Partial failures or no failures |
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.
We avoid i. e., so for this I'd suggest just "...indicates a total failure, meaning that none of the messages in the list could be sent.
Thanks Eric for reviewing the PR! @lahirumaramba I tried to push the fix to the fcm-batch-send branch but it got rejected because "Protected branch update failed for refs/heads/fcm-batch-send". Should I create another PR from dorisge/fcm-batch-send for the fix and merge it to fcm-batch-send? |
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.
Thank you! LGTM
sendAll()
andsendMulticast()
APIs.sendEach()
andsendEachForMulticast()
APIs.RELEASE NOTE:
sendAll()
andsendMulticast()
APIs are now deprecated. Please usesendEach()
andsendEachForMulticast()
APIs instead.