-
Notifications
You must be signed in to change notification settings - Fork 133
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 SendEachAsync
and SendEachForMulticastAsync
for FCM batch send
#348
Conversation
…343) * Implement `SendEachAsync` and `SendEachForMulticastAsync` `SendEachAsync` vs `SendAllAsync` 1. `SendEachAsync` sends one HTTP request to V1 Send endpoint for each message in the list. `SendAllAsync` sends only one HTTP request to V1 Batch Send endpoint to send all messages in the list. 2. `SendEachAsync` calls `Task.WhenAll` to wait for all `httpClient.SendAndDeserializeAsync` calls to complete and construct a `BatchResponse` with all `SendResponse`s. An `httpClient.SendAndDeserializeAsync` call to V1 Send endpoint either completes with a success or throws an exception. So if an exception is thrown out, the exception will be caught in `SendEachAsync` and turned into a `SendResponse` with an exception. Therefore, unlike `SendAllAsync`, `SendEachAsync` does not always throw an exception for a total failure. It can also return a `BatchResponse` with only exceptions in it. `SendEachForMulticastAsync` calls `SendEachAsync` under the hood. * Add integration tests for the batch-send reimplementation: SendEach() and SendEachForMulticast()
/// </summary> | ||
/// <exception cref="FirebaseMessagingException">If an error occurs while sending the | ||
/// messages.</exception> | ||
/// <param name="messages">Up to 500 messages to send in the batch. Cannot be null.</param> |
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.
empty ok?
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'm not sure what you mean. Could you clarify?
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.
non-null and non-empty? or just non null?
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 empty is also not ok. It's the same for SendAllAsync
, but we didn't explicitly mention this for SendAllAsync
in the past. Should I change it to "Cannot be null or empty." for both all SendAll
APIs and all SendEach
APIs? Or should I keep SendAll
API as they are now and only update the comment for SendEach
APIs?
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 kept SendAll
API unchanged and updated to "Cannot be null or empty." for all SendEach
APIs.
SendEachAsync
and SendEachForMulticastAsync
for FCM batch sendSendEachAsync
and SendEachForMulticastAsync
for 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!
@Doris-Ge Could you please clarify why sending N requests with 1 notification in each is better rather then sending 1 request with N notifications? For me that fact that I should use |
@hankovich |
Do we have similar option available in .net sdk? firebase/firebase-admin-node#2488 (comment) |
SendAllAsync
() andSendMulticastAsync
APIs.SendEachAsync
andSendEachForMulticastAsync
APIsSendEachAsync
vsSendAllAsync
SendEachAsync
sends one HTTP request to V1 Send endpoint for each message in the list.SendAllAsync
sends only one HTTP request to V1 Batch Send endpoint to send all messages in the list.SendEachAsync
callsTask.WhenAll
to wait for allhttpClient.SendAndDeserializeAsync
calls to complete and construct aBatchResponse
with allSendResponse
s. AnhttpClient.SendAndDeserializeAsync
call to V1 Send endpoint either completes with a success or throws an exception. So if an exception is thrown out, the exception will be caught inSendEachAsync
and turned into aSendResponse
with an exception. Therefore, unlikeSendAllAsync
,SendEachAsync
does not always throw an exception for a total failure. It can also return aBatchResponse
with only exceptions in it.SendEachForMulticastAsync
callsSendEachAsync
under the hood.RELEASE NOTE:
SendAllAsync()
andSendMulticastAsync()
APIs are now deprecated. UseSendEachAsync()
andSendEachForMulticastAsync()
APIs instead.