refactor: rename and modify CloserFunc

This commit is contained in:
Kevin Franklin Kim 2024-03-15 10:10:17 +01:00
parent 9745fce55c
commit e21a6e2c6b
No known key found for this signature in database
2 changed files with 11 additions and 14 deletions

View File

@ -4,14 +4,6 @@ import (
"context"
)
type CloseHandler struct {
Value func(ctx context.Context) error
}
func (r CloseHandler) Close(ctx context.Context) error {
return r.Value(ctx)
}
// Closer interface
type Closer interface {
Close()
@ -31,9 +23,3 @@ type CloserWithContext interface {
type ErrorCloserWithContext interface {
Close(ctx context.Context) error
}
func CloseFunc(v func(ctx context.Context) error) CloseHandler {
return CloseHandler{
Value: v,
}
}

11
interfaces/closerfunc.go Normal file
View File

@ -0,0 +1,11 @@
package interfaces
import (
"context"
)
type CloserFunc func(ctx context.Context) error
func (f CloserFunc) Close(ctx context.Context) error {
return f(ctx)
}