mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-23 00:27:05 +08:00
eventbus: change slow consumer event from error to warn (#3286)
Closes ipfs/kubo#10778
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user