From 5ba0d4cd5746e1ec005234c92537f7fc6ccabeb1 Mon Sep 17 00:00:00 2001 From: Alan Braithwaite Date: Thu, 4 Jul 2024 15:02:59 -0700 Subject: [PATCH] ErrorHandle -> ErrorFunc --- x/batcher/batcher.go | 8 ++++---- x/batcher/batcher_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x/batcher/batcher.go b/x/batcher/batcher.go index 4d45fc9..3609944 100644 --- a/x/batcher/batcher.go +++ b/x/batcher/batcher.go @@ -27,9 +27,9 @@ type ErrorHandler[T any] interface { HandleError(context.Context, error, []kawa.Message[T]) error } -type ErrorHandle[T any] func(context.Context, error, []kawa.Message[T]) error +type ErrorFunc[T any] func(context.Context, error, []kawa.Message[T]) error -func (ef ErrorHandle[T]) HandleError(c context.Context, err error, msgs []kawa.Message[T]) error { +func (ef ErrorFunc[T]) HandleError(c context.Context, err error, msgs []kawa.Message[T]) error { return ef(c, err, msgs) } @@ -94,11 +94,11 @@ func StopTimeout(d time.Duration) func(*Opts) { } func DiscardHandler[T any]() ErrorHandler[T] { - return ErrorHandle[T](func(context.Context, error, []kawa.Message[T]) error { return nil }) + return ErrorFunc[T](func(context.Context, error, []kawa.Message[T]) error { return nil }) } func Raise[T any]() ErrorHandler[T] { - return ErrorHandle[T](func(_ context.Context, err error, _ []kawa.Message[T]) error { return err }) + return ErrorFunc[T](func(_ context.Context, err error, _ []kawa.Message[T]) error { return err }) } // NewDestination instantiates a new batcher. diff --git a/x/batcher/batcher_test.go b/x/batcher/batcher_test.go index 43887ec..7ec00cd 100644 --- a/x/batcher/batcher_test.go +++ b/x/batcher/batcher_test.go @@ -212,7 +212,7 @@ func TestBatcherErrors(t *testing.T) { time.Sleep(110 * time.Millisecond) return flushErr } - var errHandler = ErrorHandle[string](func(c context.Context, err error, msgs []kawa.Message[string]) error { + var errHandler = ErrorFunc[string](func(c context.Context, err error, msgs []kawa.Message[string]) error { assert.ErrorIs(t, err, flushErr) return err }) @@ -263,7 +263,7 @@ func TestBatcherErrors(t *testing.T) { time.Sleep(110 * time.Millisecond) return flushErr } - var errHandler = ErrorHandle[string](func(c context.Context, err error, msgs []kawa.Message[string]) error { + var errHandler = ErrorFunc[string](func(c context.Context, err error, msgs []kawa.Message[string]) error { assert.ErrorIs(t, err, flushErr) return err })