зеркало из https://github.com/docker/go-events.git
Merge pull request #18 from aaronlehmann/avoid-logging-sink
Don't include serialization of sink in log messages
This commit is contained in:
Коммит
a7969c8a34
18
broadcast.go
18
broadcast.go
|
@ -1,6 +1,7 @@
|
|||
package events
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
|
@ -158,3 +159,20 @@ func (b *Broadcaster) run() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b Broadcaster) String() string {
|
||||
// Serialize copy of this broadcaster without the sync.once, to avoid
|
||||
// a data race.
|
||||
|
||||
b2 := Broadcaster{
|
||||
sinks: b.sinks,
|
||||
events: b.events,
|
||||
adds: b.adds,
|
||||
removes: b.removes,
|
||||
|
||||
shutdown: b.shutdown,
|
||||
closed: b.closed,
|
||||
}
|
||||
|
||||
return fmt.Sprint(b2)
|
||||
}
|
||||
|
|
15
channel.go
15
channel.go
|
@ -1,6 +1,9 @@
|
|||
package events
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Channel provides a sink that can be listened on. The writer and channel
|
||||
// listener must operate in separate goroutines.
|
||||
|
@ -46,3 +49,13 @@ func (ch *Channel) Close() error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch Channel) String() string {
|
||||
// Serialize a copy of the Channel that doesn't contain the sync.Once,
|
||||
// to avoid a data race.
|
||||
ch2 := Channel{
|
||||
C: ch.C,
|
||||
closed: ch.closed,
|
||||
}
|
||||
return fmt.Sprint(ch2)
|
||||
}
|
||||
|
|
12
retry.go
12
retry.go
|
@ -1,6 +1,7 @@
|
|||
package events
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
@ -89,6 +90,17 @@ func (rs *RetryingSink) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (rs RetryingSink) String() string {
|
||||
// Serialize a copy of the RetryingSink without the sync.Once, to avoid
|
||||
// a data race.
|
||||
rs2 := RetryingSink{
|
||||
sink: rs.sink,
|
||||
strategy: rs.strategy,
|
||||
closed: rs.closed,
|
||||
}
|
||||
return fmt.Sprint(rs2)
|
||||
}
|
||||
|
||||
// RetryStrategy defines a strategy for retrying event sink writes.
|
||||
//
|
||||
// All methods should be goroutine safe.
|
||||
|
|
Загрузка…
Ссылка в новой задаче