Debian Codegraph @

tools/channels.go

raw symbols SCIP
1 package tools
2
3 import "github.com/git-lfs/git-lfs/v3/errors"
4
5 // Interface for all types of wrapper around a channel of results and an error channel
6 // Implementors will expose a type-specific channel for results
7 // Call the Wait() function after processing the results channel to catch any errors
8 // that occurred during the async processing
9 type ChannelWrapper interface {
10 // Call this after processing results channel to check for async errors
11 Wait() error
12 }
13
14 // Base implementation of channel wrapper to just deal with errors
15 type BaseChannelWrapper struct {
16 errorChan <-chan error
17 }
18
19 func (w *BaseChannelWrapper) Wait() error {
20 var multiErr error
21 for err := range w.errorChan {
22 // Combine in case multiple errors
23 multiErr = errors.Join(multiErr, err)
24 }
25
26 return multiErr
27 }
28
29 func NewBaseChannelWrapper(errChan <-chan error) *BaseChannelWrapper {
30 return &BaseChannelWrapper{errorChan: errChan}
31 }