From 54bf0505c0dbe03f84f3b49c5925c34b515aa115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Barroso?= Date: Fri, 30 Aug 2024 17:15:29 +0100 Subject: [PATCH] chore: update constructor name (#1817) --- pkg/foundation/cerrors/fatal.go | 4 ++-- pkg/foundation/cerrors/fatal_test.go | 10 +++++----- pkg/pipeline/stream/dlq.go | 2 +- pkg/pipeline/stream/processor.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/foundation/cerrors/fatal.go b/pkg/foundation/cerrors/fatal.go index 2223007b6..3ee1a72ed 100644 --- a/pkg/foundation/cerrors/fatal.go +++ b/pkg/foundation/cerrors/fatal.go @@ -23,8 +23,8 @@ type fatalError struct { Err error } -// NewFatalError creates a new fatalError. -func NewFatalError(err error) *fatalError { +// FatalError creates a new fatalError. +func FatalError(err error) *fatalError { return &fatalError{Err: err} } diff --git a/pkg/foundation/cerrors/fatal_test.go b/pkg/foundation/cerrors/fatal_test.go index b3108bf12..2bb7dd4c3 100644 --- a/pkg/foundation/cerrors/fatal_test.go +++ b/pkg/foundation/cerrors/fatal_test.go @@ -26,7 +26,7 @@ func TestNewFatalError(t *testing.T) { is := is.New(t) err := cerrors.New("test error") - fatalErr := cerrors.NewFatalError(err) + fatalErr := cerrors.FatalError(err) wantErr := fmt.Sprintf("fatal error: %v", err) is.Equal(fatalErr.Error(), wantErr) @@ -43,12 +43,12 @@ func TestIsFatalError(t *testing.T) { }{ { name: "when it's a fatalError", - err: cerrors.NewFatalError(err), + err: cerrors.FatalError(err), want: true, }, { name: "when it's wrapped in", - err: fmt.Errorf("something went wrong: %w", cerrors.NewFatalError(cerrors.New("fatal error"))), + err: fmt.Errorf("something went wrong: %w", cerrors.FatalError(cerrors.New("fatal error"))), want: true, }, { @@ -70,7 +70,7 @@ func TestUnwrap(t *testing.T) { is := is.New(t) err := cerrors.New("test error") - fatalErr := cerrors.NewFatalError(err) + fatalErr := cerrors.FatalError(err) is.Equal(cerrors.Unwrap(fatalErr), err) } @@ -79,7 +79,7 @@ func TestFatalError(t *testing.T) { is := is.New(t) err := cerrors.New("test error") - fatalErr := cerrors.NewFatalError(err) + fatalErr := cerrors.FatalError(err) wantErr := fmt.Sprintf("fatal error: %v", err) is.Equal(fatalErr.Error(), wantErr) diff --git a/pkg/pipeline/stream/dlq.go b/pkg/pipeline/stream/dlq.go index d480ed402..b49d8e1aa 100644 --- a/pkg/pipeline/stream/dlq.go +++ b/pkg/pipeline/stream/dlq.go @@ -146,7 +146,7 @@ func (n *DLQHandlerNode) Nack(msg *Message, nackMetadata NackMetadata) (err erro ok := n.window.Nack() if !ok { - return cerrors.NewFatalError(cerrors.Errorf( + return cerrors.FatalError(cerrors.Errorf( "DLQ nack threshold exceeded (%d/%d), original error: %w", n.WindowNackThreshold, n.WindowSize, nackMetadata.Reason, )) diff --git a/pkg/pipeline/stream/processor.go b/pkg/pipeline/stream/processor.go index 81ac298aa..540c6b774 100644 --- a/pkg/pipeline/stream/processor.go +++ b/pkg/pipeline/stream/processor.go @@ -112,7 +112,7 @@ func (n *ProcessorNode) Run(ctx context.Context) error { case sdk.ErrorRecord: err = msg.Nack(v.Error, n.ID()) if err != nil { - return cerrors.NewFatalError(cerrors.Errorf("error executing processor: %w", err)) + return cerrors.FatalError(cerrors.Errorf("error executing processor: %w", err)) } } }