Skip to content

Commit 761eb88

Browse files
authored
Enabling HTTP retries for FCM and IID (#217)
* Enabling HTTP retries for FCM and IID * Disabling retries for tests
1 parent 6ea9a02 commit 761eb88

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- [added] Implemented HTTP retries for the `db` package. This package
44
now retries HTTP calls on low-level connection and socket read errors, as
55
well as HTTP 500 and 503 errors.
6+
- [fixed] Updated `messaging.Client` and `iid.Client` to use the new
7+
HTTP client API with retries support.
68

79
# v3.6.0
810

iid/iid.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"net/http"
2323

2424
"firebase.google.com/go/internal"
25-
"google.golang.org/api/transport"
2625
)
2726

2827
const iidEndpoint = "https://console.firebase.google.com/v1"
@@ -117,14 +116,14 @@ func NewClient(ctx context.Context, c *internal.InstanceIDConfig) (*Client, erro
117116
return nil, errors.New("project id is required to access instance id client")
118117
}
119118

120-
hc, _, err := transport.NewHTTPClient(ctx, c.Opts...)
119+
hc, _, err := internal.NewHTTPClient(ctx, c.Opts...)
121120
if err != nil {
122121
return nil, err
123122
}
124123

125124
return &Client{
126125
endpoint: iidEndpoint,
127-
client: &internal.HTTPClient{Client: hc},
126+
client: hc,
128127
project: c.ProjectID,
129128
}, nil
130129
}

iid/iid_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func TestDeleteInstanceIDError(t *testing.T) {
101101
t.Fatal(err)
102102
}
103103
client.endpoint = ts.URL
104+
client.client.RetryConfig = nil
104105

105106
errorHandlers := map[int]func(error) bool{
106107
http.StatusBadRequest: IsInvalidArgument,

messaging/messaging.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"time"
2929

3030
"firebase.google.com/go/internal"
31-
"google.golang.org/api/transport"
3231
)
3332

3433
const (
@@ -653,15 +652,15 @@ func NewClient(ctx context.Context, c *internal.MessagingConfig) (*Client, error
653652
return nil, errors.New("project ID is required to access Firebase Cloud Messaging client")
654653
}
655654

656-
hc, _, err := transport.NewHTTPClient(ctx, c.Opts...)
655+
hc, _, err := internal.NewHTTPClient(ctx, c.Opts...)
657656
if err != nil {
658657
return nil, err
659658
}
660659

661660
return &Client{
662661
fcmEndpoint: messagingEndpoint,
663662
iidEndpoint: iidEndpoint,
664-
client: &internal.HTTPClient{Client: hc},
663+
client: hc,
665664
project: c.ProjectID,
666665
version: "Go/Admin/" + c.Version,
667666
}, nil

messaging/messaging_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ func TestSendError(t *testing.T) {
962962
t.Fatal(err)
963963
}
964964
client.fcmEndpoint = ts.URL
965+
client.client.RetryConfig = nil
965966

966967
cases := []struct {
967968
resp, want string
@@ -1150,6 +1151,7 @@ func TestTopicManagementError(t *testing.T) {
11501151
t.Fatal(err)
11511152
}
11521153
client.iidEndpoint = ts.URL
1154+
client.client.RetryConfig = nil
11531155

11541156
cases := []struct {
11551157
resp, want string

0 commit comments

Comments
 (0)