File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,20 +12,25 @@ import (
1212
1313type CloseFn func (ctx context.Context ) error
1414
15- // Closer allows to register functions to clean up resources.
15+ // Closer cleans up resources.
1616type Closer interface {
17+ Adder
1718 // SetContext sets context which will be passed into the close functions without cancel.
1819 SetContext (ctx context.Context )
19- // Add adds close function.
20- Add (CloseFn )
2120 // Done returns signal channel.
2221 Done () <- chan struct {}
23- // Err returns joint error based on close functions errors.
22+ // Err returns a joint error based on close functions errors.
2423 Err () error
2524 // CloseAll runs close functions in arbitrary order.
2625 CloseAll ()
2726}
2827
28+ // Adder allows registering functions to clean up resources.
29+ type Adder interface {
30+ // Add adds close function.
31+ Add (CloseFn )
32+ }
33+
2934type closer struct {
3035 done chan struct {}
3136 ctx atomic.Pointer [context.Context ]
You can’t perform that action at this time.
0 commit comments