Skip to content

Commit 52e25e8

Browse files
committed
Update go-pkgz/repeater dependency to v2
Switch from repeater v1 to v2, which provides improved retry functionality. Update NewDefault to NewFixed as per v2 API changes. Adjust test timing expectation to account for v2's delay behavior (delays between attempts rather than before each attempt).
1 parent ab7f664 commit 52e25e8

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

email.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ type SMTPParams struct {
1616
Host string // SMTP host
1717
Port int // SMTP port
1818
TLS bool // TLS auth
19-
StartTLS bool // StartTLS auth
19+
StartTLS bool // startTLS auth
2020
InsecureSkipVerify bool // skip certificate verification
21-
ContentType string // Content type
22-
Charset string // Character set
21+
ContentType string // content type
22+
Charset string // character set
2323
LoginAuth bool // LOGIN auth method instead of default PLAIN, needed for Office 365 and outlook.com
2424
Username string // username
2525
Password string // password

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.0
55
require (
66
github.com/go-pkgz/email v0.6.0
77
github.com/go-pkgz/lgr v0.12.1
8-
github.com/go-pkgz/repeater v1.2.0
8+
github.com/go-pkgz/repeater/v2 v2.2.0
99
github.com/microcosm-cc/bluemonday v1.0.27
1010
github.com/slack-go/slack v0.17.3
1111
github.com/stretchr/testify v1.11.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/go-pkgz/email v0.6.0 h1:snZnXldjeF4PgKSjnx9Fa25mtOgFpAOEeWvnQvrxjLE=
66
github.com/go-pkgz/email v0.6.0/go.mod h1:+wgi4x7S33IuCzfcCM5euN0GwQG6XvO/PBLxrNffYLI=
77
github.com/go-pkgz/lgr v0.12.1 h1:8GVfG2rSARq3Eaj5PP158rtBR2LHVGkwioIkQBGbvKg=
88
github.com/go-pkgz/lgr v0.12.1/go.mod h1:A4AxjOthFVFK6jRnVYMeusno5SeDAxcLVHd0kI/lN/Y=
9-
github.com/go-pkgz/repeater v1.2.0 h1:oJFvjyKdTDd5RCzpzxlzYIZFFj6Zfl17rE1aUfu6UjQ=
10-
github.com/go-pkgz/repeater v1.2.0/go.mod h1:vypP6xamA53MFmafnGUucqOmALKk36xgKu2hSG73LHM=
9+
github.com/go-pkgz/repeater/v2 v2.2.0 h1:8nZR/NaknmLfx2YMHbr78u9OL4Xj+8+romm9dz4FpMg=
10+
github.com/go-pkgz/repeater/v2 v2.2.0/go.mod h1:RgX5vUbLKq7PV82QUDP5pFbQS1os4Z+U9XzKymK23A8=
1111
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
1212
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
1313
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=

telegram.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"time"
1717

1818
log "github.com/go-pkgz/lgr"
19-
"github.com/go-pkgz/repeater"
19+
"github.com/go-pkgz/repeater/v2"
2020
"github.com/microcosm-cc/bluemonday"
2121
"golang.org/x/net/html"
2222
)
@@ -34,8 +34,8 @@ type TelegramParams struct {
3434
type Telegram struct {
3535
TelegramParams
3636

37-
// Identifier of the first update to be requested.
38-
// Should be equal to LastSeenUpdateID + 1
37+
// identifier of the first update to be requested.
38+
// should be equal to LastSeenUpdateID + 1
3939
// See https://core.telegram.org/bots/api#getupdates
4040
updateOffset int
4141
apiPollInterval time.Duration // interval to check updates from Telegram API and answer to users
@@ -247,7 +247,7 @@ func (t *Telegram) CheckToken(token, user string) (telegram, site string, err er
247247
return "", "", errors.New("user does not match original requester")
248248
}
249249

250-
// Delete request
250+
// delete request
251251
t.requests.Lock()
252252
delete(t.requests.data, token)
253253
t.requests.Unlock()
@@ -387,7 +387,7 @@ func (t *Telegram) processUpdates(ctx context.Context, updates *TelegramUpdate)
387387

388388
t.requests.RLock()
389389
authRequest, ok := t.requests.data[token]
390-
if !ok { // No such token
390+
if !ok { // no such token
391391
t.requests.RUnlock()
392392
if t.ErrorMsg != "" {
393393
if err := t.sendText(ctx, update.Message.Chat.ID, t.ErrorMsg); err != nil {
@@ -436,7 +436,7 @@ func (t *Telegram) botInfo(ctx context.Context) (*TelegramBotInfo, error) {
436436

437437
// Request makes a request to the Telegram API and return the result
438438
func (t *Telegram) Request(ctx context.Context, method string, b []byte, data any) error {
439-
return repeater.NewDefault(3, time.Millisecond*250).Do(ctx, func() error {
439+
return repeater.NewFixed(3, time.Millisecond*250).Do(ctx, func() error {
440440
url := fmt.Sprintf("%s%s/%s", t.apiPrefix, t.Token, method)
441441

442442
var req *http.Request

telegram_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestTelegram_New(t *testing.T) {
4040
})
4141
require.Error(t, err)
4242
assert.Contains(t, err.Error(), "failed to decode json response:")
43-
assert.GreaterOrEqual(t, time.Since(st), 250*3*time.Millisecond)
43+
assert.GreaterOrEqual(t, time.Since(st), 250*2*time.Millisecond)
4444

4545
_, err = NewTelegram(TelegramParams{
4646
Token: "404",

0 commit comments

Comments
 (0)