mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
refactor: rename and modify CloserFunc
This commit is contained in:
parent
9745fce55c
commit
e21a6e2c6b
@ -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
11
interfaces/closerfunc.go
Normal 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)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user