-
Notifications
You must be signed in to change notification settings - Fork 407
Implement sendEach and sendEachForMulticast
#2097
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
Conversation
`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.
| * Sends each message in the given array via Firebase Cloud Messaging. | ||
| * | ||
| * Unlike {@link Messaging.sendAll}, this method makes a single RPC call for each message in the given array. | ||
| * Unlike {@link Messaging.sendAll}, this method makes a single RPC call for each message |
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.
Should this be a RPC call or an HTTP call?
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.
I think we use RPC in other places in the SDK. Let's get the docs reviewed so we can address all these naming issues. Thanks!
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.
Sounds good! Based on the implementation, I think we actually send an HTTP call instead of an internal RPC call. I can leave this as it is now.
lahirumaramba
left a comment
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 @Doris-Ge ! Looks great!
Let's get the docs reviewed. Feel free to do it now or later when you make the merge to the main branch. Thanks!
…nd (#2138) * Deprecate sendAll and sendMulticast (#2094) 1. Deprecate sendAll and sendMulticast 2. Add dummy implementation for sendEach and sendEachForMulticast to avoid errors reported by api-extractor * Implement `sendEach` and `sendEachForMulticast` (#2097) `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. * Add integration tests for `sendEach` and `sendMulticast` (#2130) * Avoid using "-- i.e." in the function comment
sendEachvssendAllsendEachsends one HTTP request to V1 Send endpoint for each message in the array.sendAllsends only one HTTP request to V1 Batch Send endpoint to send all messages in the array.sendEachcallsPromise.allSettledto wait for allhttpClient.sendcalls to complete and construct aBatchResponse. AnhttpClient.sendcall 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 insendEachand turned into aSendResponsewith an error. Therefore, unlikesendAll,sendEachdoes not always throw an error for a total failure. It can also return aBatchResponsewith only errors in it.sendEachForMulticastcallssendEachunder the hood.