Skip to content

Commit fe069ee

Browse files
authored
Merge pull request #258 from go-pkgz/upgrade-repeater-v2
upgrade go-pkgz/repeater to v2
2 parents 2416d11 + 10c4591 commit fe069ee

12 files changed

Lines changed: 38 additions & 24 deletions

File tree

.github/workflows/ci-v2.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ on:
77
paths:
88
- ".github/workflows/ci-v2.yml"
99
- "v2/**"
10+
- "_example/**"
1011
pull_request:
1112
paths:
1213
- ".github/workflows/ci-v2.yml"
1314
- "v2/**"
15+
- "_example/**"
1416

1517
jobs:
1618
build:
@@ -37,6 +39,13 @@ jobs:
3739
with:
3840
mongoDBVersion: "6.0"
3941

42+
- name: build the example
43+
working-directory: _example
44+
run: |
45+
go build -race
46+
env:
47+
TZ: "America/Chicago"
48+
4049
- name: build and test
4150
run: |
4251
go test -timeout=60s -v -race -p 1 -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov ./...

.github/workflows/ci.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ on:
77
paths-ignore:
88
- ".github/workflows/ci-v2.yml"
99
- "v2/**"
10+
- "_example/**"
1011
pull_request:
1112
paths-ignore:
1213
- ".github/workflows/ci-v2.yml"
1314
- "v2/**"
15+
- "_example/**"
1416

1517
jobs:
1618
build:
@@ -36,13 +38,6 @@ jobs:
3638
with:
3739
mongoDBVersion: "6.0"
3840

39-
- name: build the example
40-
working-directory: _example
41-
run: |
42-
go build -race
43-
env:
44-
TZ: "America/Chicago"
45-
4641
- name: build and test
4742
run: |
4843
go test -timeout=60s -v -race -p 1 -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov ./...

_example/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
require (
1818
cloud.google.com/go/compute/metadata v0.9.0 // indirect
1919
github.com/dghubble/oauth1 v0.7.3 // indirect
20-
github.com/go-pkgz/repeater v1.2.0 // indirect
20+
github.com/go-pkgz/repeater/v2 v2.0.1 // indirect
2121
github.com/golang/snappy v1.0.0 // indirect
2222
github.com/google/uuid v1.6.0 // indirect
2323
github.com/klauspost/compress v1.18.2 // indirect

_example/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/go-oauth2/oauth2/v4 v4.5.4 h1:YjI0tmGW8oxVhn9QSBIxlr641QugWrJY5UWa6Xm
1616
github.com/go-oauth2/oauth2/v4 v4.5.4/go.mod h1:BXiOY+QZtZy2ewbsGk2B5P8TWmtz/Rf7ES5ZttQFxfQ=
1717
github.com/go-pkgz/lgr v0.12.1 h1:8GVfG2rSARq3Eaj5PP158rtBR2LHVGkwioIkQBGbvKg=
1818
github.com/go-pkgz/lgr v0.12.1/go.mod h1:A4AxjOthFVFK6jRnVYMeusno5SeDAxcLVHd0kI/lN/Y=
19-
github.com/go-pkgz/repeater v1.2.0 h1:oJFvjyKdTDd5RCzpzxlzYIZFFj6Zfl17rE1aUfu6UjQ=
20-
github.com/go-pkgz/repeater v1.2.0/go.mod h1:vypP6xamA53MFmafnGUucqOmALKk36xgKu2hSG73LHM=
19+
github.com/go-pkgz/repeater/v2 v2.0.1 h1:um4pnVvWa5vNUv5f0SaiowvSHIy33sSFSc/W6rx0Eks=
20+
github.com/go-pkgz/repeater/v2 v2.0.1/go.mod h1:RgX5vUbLKq7PV82QUDP5pFbQS1os4Z+U9XzKymK23A8=
2121
github.com/go-pkgz/rest v1.20.4 h1:8ufcP1IqoDhCvIFdXPtvyX4HSS16SM6THBe2a6L0/kg=
2222
github.com/go-pkgz/rest v1.20.4/go.mod h1:2/LEZGndSxpVvExsMn48AjUgiTn6kILqjpoaRnl62JU=
2323
github.com/go-pkgz/routegroup v1.6.0 h1:44XHZgF6JIIldRlv+zjg6SygULASmjifnfIQjwCT0e4=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dghubble/oauth1 v0.7.3
77
github.com/go-oauth2/oauth2/v4 v4.5.2
88
github.com/go-pkgz/email v0.6.0
9-
github.com/go-pkgz/repeater v1.2.0
9+
github.com/go-pkgz/repeater/v2 v2.0.1
1010
github.com/go-pkgz/rest v1.20.4
1111
github.com/golang-jwt/jwt v3.2.2+incompatible
1212
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ github.com/go-oauth2/oauth2/v4 v4.5.2 h1:CuZhD3lhGuI6aNLyUbRHXsgG2RwGRBOuCBfd4WQ
2121
github.com/go-oauth2/oauth2/v4 v4.5.2/go.mod h1:wk/2uLImWIa9VVQDgxz99H2GDbhmfi/9/Xr+GvkSUSQ=
2222
github.com/go-pkgz/email v0.6.0 h1:snZnXldjeF4PgKSjnx9Fa25mtOgFpAOEeWvnQvrxjLE=
2323
github.com/go-pkgz/email v0.6.0/go.mod h1:+wgi4x7S33IuCzfcCM5euN0GwQG6XvO/PBLxrNffYLI=
24-
github.com/go-pkgz/repeater v1.2.0 h1:oJFvjyKdTDd5RCzpzxlzYIZFFj6Zfl17rE1aUfu6UjQ=
25-
github.com/go-pkgz/repeater v1.2.0/go.mod h1:vypP6xamA53MFmafnGUucqOmALKk36xgKu2hSG73LHM=
24+
github.com/go-pkgz/repeater/v2 v2.0.1 h1:um4pnVvWa5vNUv5f0SaiowvSHIy33sSFSc/W6rx0Eks=
25+
github.com/go-pkgz/repeater/v2 v2.0.1/go.mod h1:RgX5vUbLKq7PV82QUDP5pFbQS1os4Z+U9XzKymK23A8=
2626
github.com/go-pkgz/rest v1.20.4 h1:8ufcP1IqoDhCvIFdXPtvyX4HSS16SM6THBe2a6L0/kg=
2727
github.com/go-pkgz/rest v1.20.4/go.mod h1:2/LEZGndSxpVvExsMn48AjUgiTn6kILqjpoaRnl62JU=
2828
github.com/go-session/session v3.1.2+incompatible/go.mod h1:8B3iivBQjrz/JtC68Np2T1yBBLxTan3mn/3OM0CyRt0=

provider/telegram.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"sync/atomic"
1616
"time"
1717

18-
"github.com/go-pkgz/repeater"
18+
"github.com/go-pkgz/repeater/v2"
1919
"github.com/go-pkgz/rest"
2020
"github.com/golang-jwt/jwt"
2121

@@ -450,7 +450,7 @@ func (tg *tgAPI) BotInfo(ctx context.Context) (*botInfo, error) {
450450
}
451451

452452
func (tg *tgAPI) request(ctx context.Context, method string, data interface{}) error {
453-
return repeater.NewDefault(3, time.Millisecond*50).Do(ctx, func() error {
453+
return repeater.NewFixed(3, time.Millisecond*50).Do(ctx, func() error {
454454
url := fmt.Sprintf("https://api.telegram.org/bot%s/%s", tg.token, method)
455455

456456
req, err := http.NewRequestWithContext(ctx, "GET", url, http.NoBody)

provider/telegram_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,16 @@ func TestTelegram_ProcessUpdateFlow(t *testing.T) {
309309
assert.Equal(t, "my_auth_bot", resp.Bot)
310310

311311
ctx, cancel := context.WithCancel(context.Background())
312-
defer cancel()
313-
go tg.Run(ctx)
312+
runDone := make(chan struct{})
313+
go func() {
314+
_ = tg.Run(ctx)
315+
close(runDone)
316+
}()
314317
assert.Eventually(t, func() bool {
315318
return tg.ProcessUpdate(ctx, "").Error() == "Run goroutine should not be used with ProcessUpdate"
316319
}, time.Millisecond*100, time.Millisecond*10, "ProcessUpdate should not work same time as Run")
320+
cancel()
321+
<-runDone
317322
}
318323

319324
func TestTelegram_TokenVerification(t *testing.T) {

v2/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dghubble/oauth1 v0.7.3
77
github.com/go-oauth2/oauth2/v4 v4.5.4
88
github.com/go-pkgz/email v0.6.0
9-
github.com/go-pkgz/repeater v1.2.0
9+
github.com/go-pkgz/repeater/v2 v2.0.1
1010
github.com/go-pkgz/rest v1.20.4
1111
github.com/golang-jwt/jwt/v5 v5.3.0
1212
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d

v2/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/go-oauth2/oauth2/v4 v4.5.4 h1:YjI0tmGW8oxVhn9QSBIxlr641QugWrJY5UWa6Xm
1616
github.com/go-oauth2/oauth2/v4 v4.5.4/go.mod h1:BXiOY+QZtZy2ewbsGk2B5P8TWmtz/Rf7ES5ZttQFxfQ=
1717
github.com/go-pkgz/email v0.6.0 h1:snZnXldjeF4PgKSjnx9Fa25mtOgFpAOEeWvnQvrxjLE=
1818
github.com/go-pkgz/email v0.6.0/go.mod h1:+wgi4x7S33IuCzfcCM5euN0GwQG6XvO/PBLxrNffYLI=
19-
github.com/go-pkgz/repeater v1.2.0 h1:oJFvjyKdTDd5RCzpzxlzYIZFFj6Zfl17rE1aUfu6UjQ=
20-
github.com/go-pkgz/repeater v1.2.0/go.mod h1:vypP6xamA53MFmafnGUucqOmALKk36xgKu2hSG73LHM=
19+
github.com/go-pkgz/repeater/v2 v2.0.1 h1:um4pnVvWa5vNUv5f0SaiowvSHIy33sSFSc/W6rx0Eks=
20+
github.com/go-pkgz/repeater/v2 v2.0.1/go.mod h1:RgX5vUbLKq7PV82QUDP5pFbQS1os4Z+U9XzKymK23A8=
2121
github.com/go-pkgz/rest v1.20.4 h1:8ufcP1IqoDhCvIFdXPtvyX4HSS16SM6THBe2a6L0/kg=
2222
github.com/go-pkgz/rest v1.20.4/go.mod h1:2/LEZGndSxpVvExsMn48AjUgiTn6kILqjpoaRnl62JU=
2323
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=

0 commit comments

Comments
 (0)