firebase / firebase-admin-python

Firebase Admin Python SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
988 stars 301 forks source link

feat(fcm): Add `send_each` and `send_each_for_multicast` for FCM batch send #706

Closed Doris-Ge closed 1 year ago

Doris-Ge commented 1 year ago

send_each vs send_all

  1. send_each sends one HTTP request to V1 Send endpoint for each message in the list. send_all sends only one HTTP request to V1 Batch Send endpoint to send all messages in the array.
  2. send_each uses concurrent.futures.ThreadPoolExecutor to run and wait for all request calls to complete and construct a BatchResponse. An request 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 send_each and turned into a SendResponse with an exception. Therefore, unlike send_all, send_each does not always throw an exception for a total failure. It can also return a BatchResponse with only exceptions in it.

send_each_for_multicast calls send_each under the hood.

RELEASE NOTE: send_all() and send_multicast() APIs are now deprecated. Use send_each() and send_each_for_multicast() APIs instead.