From c6b68a096cbed6cf4d583543218c6c0d5c724f64 Mon Sep 17 00:00:00 2001 From: Karen Chen Date: Mon, 22 Apr 2024 15:07:04 -0700 Subject: [PATCH] remove deprecated LockRenewalHandler (#218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stéphane Erbrech --- v2/lockrenewer.go | 12 ------------ v2/lockrenewer_test.go | 17 ----------------- 2 files changed, 29 deletions(-) diff --git a/v2/lockrenewer.go b/v2/lockrenewer.go index d5c6b45f..3cf09ce4 100644 --- a/v2/lockrenewer.go +++ b/v2/lockrenewer.go @@ -7,7 +7,6 @@ import ( "sync/atomic" "time" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -65,17 +64,6 @@ func NewLockRenewalHandler(lockRenewer LockRenewer, options *LockRenewalOptions, } } -// Deprecated: use NewLockRenewalHandler -// NewRenewLockHandler starts a renewlock goroutine for each message received. -func NewRenewLockHandler(lockRenewer LockRenewer, interval *time.Duration, handler Handler) HandlerFunc { - return NewLockRenewalHandler(lockRenewer, - &LockRenewalOptions{ - Interval: interval, - // default to false on the old handler signature to keep the same behavior - CancelMessageContextOnStop: to.Ptr(false)}, - handler) -} - // peekLockRenewer starts a background goroutine that renews the message lock at the given interval until Stop() is called // or until the passed in context is canceled. // it is a pass through handler if the renewalInterval is nil diff --git a/v2/lockrenewer_test.go b/v2/lockrenewer_test.go index a444f57c..57a9f79d 100644 --- a/v2/lockrenewer_test.go +++ b/v2/lockrenewer_test.go @@ -128,23 +128,6 @@ func Test_RenewPeriodically(t *testing.T) { 20*time.Millisecond).Should(Succeed()) } -//nolint:staticcheck // still need to cover the deprecated func -func Test_NewLockRenewerHandler_defaultToNotCancelMessageContext(t *testing.T) { - g := NewWithT(t) - interval := 20 * time.Millisecond - sbRenewer := &fakeSBLockRenewer{ - Err: &azservicebus.Error{Code: azservicebus.CodeLockLost}, - } - - handler := shuttle.NewRenewLockHandler(sbRenewer, &interval, - shuttle.HandlerFunc(func(ctx context.Context, settler shuttle.MessageSettler, message *azservicebus.ReceivedMessage) { - g.Consistently(func(g Gomega) { - g.Expect(ctx.Err()).To(BeNil()) - }, "120ms", "10ms").Should(Succeed()) - })) - handler.Handle(context.Background(), &fakeSettler{}, &azservicebus.ReceivedMessage{}) -} - func Test_RenewPeriodically_Error(t *testing.T) { type testCase struct { name string