eventbus: change slow consumer event from error to warn (#3286)

Closes ipfs/kubo#10778
This commit is contained in:
Guillaume Michel
2025-05-15 20:11:34 +02:00
committed by GitHub
parent 813d78c0ee
commit c1c77458c2
2 changed files with 10 additions and 3 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ import (
type logInterface interface {
Errorf(string, ...interface{})
Warnf(string, ...interface{})
}
var log logInterface = logging.Logger("eventbus")
@@ -464,7 +465,7 @@ func emitAndLogError(timer *time.Timer, typ reflect.Type, evt interface{}, sink
<-timer.C
}
case <-timer.C:
log.Errorf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ)
log.Warnf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ)
// Continue to stall since there's nothing else we can do.
sink.ch <- evt
}
+8 -2
View File
@@ -18,8 +18,10 @@ import (
"github.com/stretchr/testify/require"
)
type EventA struct{}
type EventB int
type (
EventA struct{}
EventB int
)
func getN() int {
n := 50000
@@ -144,6 +146,10 @@ func (m *mockLogger) Errorf(format string, args ...interface{}) {
m.logs = append(m.logs, fmt.Sprintf(format, args...))
}
func (m *mockLogger) Warnf(format string, args ...interface{}) {
m.Errorf(format, args...)
}
func (m *mockLogger) Logs() []string {
m.mu.Lock()
defer m.mu.Unlock()