-
Notifications
You must be signed in to change notification settings - Fork 144
feat(fcm): Implement SendEachAsync and SendEachForMulticastAsync
#343
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
`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.
27e6ee1 to
6d6b20f
Compare
| } | ||
| catch (Exception e) | ||
| { | ||
| var exception = new FirebaseMessagingException(ErrorCode.Unknown, $"{e}"); |
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.
Is it ok to put the exception into the SendResponse?
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.
Seems like that's how we have handled exceptions in batch send. Add the responses in var responses = new List<SendResponse>(); with SendResponse.FromException(... for failed once.
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.
Sorry for the late response! My question was about whether it's ok to put the content of the Exception e into the SendResponse via $"{e}". Sorry for being unclear!
SendEach() and SendEachForMulticast()
SendEachAsync and SendEachForMulticastAsyncSendEachAsync and SendEachForMulticastAsync
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.
LGTM! Thank you!
| } | ||
| catch (Exception e) | ||
| { | ||
| var exception = new FirebaseMessagingException(ErrorCode.Unknown, $"{e}"); |
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.
Seems like that's how we have handled exceptions in batch send. Add the responses in var responses = new List<SendResponse>(); with SendResponse.FromException(... for failed once.
…M batch send (#348) * feat(fcm): Implement `SendEachAsync` and `SendEachForMulticastAsync` (#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() * Address the doc review comments
…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()
SendEachAsyncvsSendAllAsyncSendEachAsyncsends one HTTP request to V1 Send endpoint for each message in the list.SendAllAsyncsends only one HTTP request to V1 Batch Send endpoint to send all messages in the list.SendEachAsynccallsTask.WhenAllto wait for allhttpClient.SendAndDeserializeAsynccalls to complete and construct aBatchResponsewith allSendResponses. AnhttpClient.SendAndDeserializeAsynccall 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 inSendEachAsyncand turned into aSendResponsewith an exception. Therefore, unlikeSendAllAsync,SendEachAsyncdoes not always throw an exception for a total failure. It can also return aBatchResponsewith only exceptions in it.SendEachForMulticastAsynccallsSendEachAsyncunder the hood.