Implement sendEach and sendEachForMulticast#2097
Merged
Merged
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.
Doris-Ge
commented
Mar 5, 2023
| * 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 |
Contributor
Author
There was a problem hiding this comment.
Should this be a RPC call or an HTTP call?
Member
There was a problem hiding this comment.
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!
Contributor
Author
There was a problem hiding this comment.
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
approved these changes
Mar 23, 2023
Member
lahirumaramba
left a comment
There was a problem hiding this comment.
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!
Doris-Ge
added a commit
that referenced
this pull request
Apr 12, 2023
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.