-
Notifications
You must be signed in to change notification settings - Fork 269
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): Implement sendEach
, sendEachAsync
, sendEachForMulticast
and sendEachForMulticastAsync
(#785)
#815
Conversation
…st` and `sendEachForMulticastAsync` (#785) * Add org.hamcrest as dependency for unit tests * Implement sendEach, sendEachAsync, sendEachForMulticast and sendEachForMulticastAsync `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 `messagingClient.send` to send each message and constructs a `SendResponse` with the returned `messageId`. If `messagingClient.send` throws out an exception, `sendEach` will catch the exception and also turn it into a `SendResponse` with the exception in it. `sendEach` calls `ApiFutures.allAsList().get()` to execute all `messagingClient.send` calls asynchronously and wait for all of them to complete and construct a `BatchResponse` with all `SendResponse`s. 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. `sendEachAsync` is the async version of `sendEach`. `sendEachForMulticastAsync` is the async version of `sendEachForMulticast`. * Add integration tests for batch-send re-implementation: testSendEach(), testSendFiveHundredWithSendEach(), testSendEachForMulticast()
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!
Please get the docs reviewed if we haven't done so already in the fcm-batch-send
branch.
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.
A few style things for you Doris! Otherwise, LGTM from a doc string perspective, thanks!
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
Kevin and Eric, thank you both for reviewing the PR! All the comments have been resolved. Merging this PR to the branch. |
What new method is equivalent to |
Hi @Doris-Ge @lahirumaramba , Could you please provide your inputs to the folllowing questions.
I appreciate your response. |
|
Add org.hamcrest as dependency for unit tests
Implement sendEach, sendEachAsync, sendEachForMulticast and sendEachForMulticastAsync
sendEach
vssendAll
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.sendEach
callsmessagingClient.send
to send each message and constructs aSendResponse
with the returnedmessageId
. IfmessagingClient.send
throws out an exception,sendEach
will catch the exception and also turn it into aSendResponse
with the exception in it.sendEach
callsApiFutures.allAsList().get()
to execute allmessagingClient.send
calls asynchronously and wait for all of them to complete and construct aBatchResponse
with allSendResponse
s. Therefore, unlikesendAll
,sendEach
does not always throw an error for a total failure. It can also return aBatchResponse
with only errors in it.sendEachForMulticast
callssendEach
under the hood.sendEachAsync
is the async version ofsendEach
.sendEachForMulticastAsync
is the async version ofsendEachForMulticast
.RELEASE NOTE:
sendAll()
,sendAllAsync()
,sendMulticast()
, andsendMulticastAsync()
APIs are now deprecated. UsesendEach()
,sendEachAsync()
,sendEachForMulticast()
, andsendEachForMulticastAsync()
APIs instead.