mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
156c83d112
* app/vmalert: support multiple notifier urls (#584) User now can set multiple notifier URLs in the same fashion as for other vmutils (e.g. vmagent). The same is correct for TLS setting for every configured URL. Alerts sending is done in sequential way for respecting the specified URLs order. * app/vmalert: add basicAuth support for notifier client (#585) The change adds possibility to set basicAuth creds for notifier client in the same fasion as for remote write/read and datasource.
44 lines
766 B
Go
44 lines
766 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// ErrGroup accumulates multiple errors
|
|
// and produces single error message.
|
|
type ErrGroup struct {
|
|
errs []error
|
|
}
|
|
|
|
// Add adds a new error to group.
|
|
// Isn't thread-safe.
|
|
func (eg *ErrGroup) Add(err error) {
|
|
eg.errs = append(eg.errs, err)
|
|
}
|
|
|
|
// Err checks if group contains at least
|
|
// one error.
|
|
func (eg *ErrGroup) Err() error {
|
|
if eg == nil || len(eg.errs) == 0 {
|
|
return nil
|
|
}
|
|
return eg
|
|
}
|
|
|
|
// Error satisfies Error interface
|
|
func (eg *ErrGroup) Error() string {
|
|
if len(eg.errs) == 0 {
|
|
return ""
|
|
}
|
|
var b strings.Builder
|
|
fmt.Fprintf(&b, "errors(%d): ", len(eg.errs))
|
|
for i, err := range eg.errs {
|
|
b.WriteString(err.Error())
|
|
if i != len(eg.errs)-1 {
|
|
b.WriteString("\n")
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|