firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.12k stars 239 forks source link

Implement `SendEach`, `SendEachDryRun`, `SendEachForMulticast`, #544

Closed Doris-Ge closed 1 year ago

Doris-Ge commented 1 year ago

SendEachForMulticastDryRun

  1. Add SendEach, SendEachDryRun, SendEachForMulticast, SendEachForMulticastDryRun
  2. Deprecate SendAll, SendAllDryRun, SendMulticast, SendMulticastDryRun

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 fcmClient.Send to send each message and constructs a SendResponse with the returned message id or error. SendEach uses sync.WaitGroup to execute all fcmClient.Send calls asynchronously and wait for all of them to complete and construct a BatchResponse with all SendResponses. Therefore, unlike SendAll, SendEach does not always returns an error for a total failure. It can also return a BatchResponse with only errors in it.

SendEachForMulticast calls SendEach under the hood.

Will send the integration tests in another PR.

lahirumaramba commented 1 year ago

Please make sure that this branch is based off of dev and not mater. In the Go repo, we make all the new changes in the dev branch and only the releases are merged to the main (master) branch. Thank you!

Doris-Ge commented 1 year ago

Please make sure that this branch is based off of dev and not mater. In the Go repo, we make all the new changes in the dev branch and only the releases are merged to the main (master) branch. Thank you! Thanks for letting me know that! I tried git push but it always got rejected, so I created a PR to merge dev into this branch because dev is only one commit ahead of this branch.