mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00
poller error formatting
This commit is contained in:
parent
3bd8aca2d2
commit
40c4344f73
1 changed files with 4 additions and 6 deletions
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
)
|
)
|
||||||
|
@ -85,13 +85,11 @@ func (p *Poller[T, AggregateT]) gatherErrs() (string, bool) {
|
||||||
if len(p.errs) == 0 {
|
if len(p.errs) == 0 {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
title := fmt.Sprintf("Poller %s has encountered %d errors in the last %s seconds:", p.name, len(p.errs), gatherErrsInterval)
|
errs := E.NewBuilder(fmt.Sprintf("poller %s has encountered %d errors in the last %s:", p.name, len(p.errs), gatherErrsInterval))
|
||||||
errs := make([]string, 0, len(p.errs)+1)
|
|
||||||
errs = append(errs, title)
|
|
||||||
for _, e := range p.errs {
|
for _, e := range p.errs {
|
||||||
errs = append(errs, fmt.Sprintf("%s: %d times", e.err.Error(), e.count))
|
errs.Addf("%w: %d times", e.err, e.count)
|
||||||
}
|
}
|
||||||
return strings.Join(errs, "\n"), true
|
return errs.String(), true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Poller[T, AggregateT]) clearErrs() {
|
func (p *Poller[T, AggregateT]) clearErrs() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue