all: Implement suture v4-api (#6947)

This commit is contained in:
Simon Frei
2020-11-17 13:19:04 +01:00
committed by GitHub
parent e8fc465ea8
commit 9524b51708
65 changed files with 617 additions and 693 deletions
+5 -6
View File
@@ -15,10 +15,9 @@ import (
"runtime"
"time"
"github.com/thejerf/suture"
"github.com/thejerf/suture/v4"
"github.com/syncthing/syncthing/lib/sync"
"github.com/syncthing/syncthing/lib/util"
)
type EventType int64
@@ -219,7 +218,6 @@ type Logger interface {
}
type logger struct {
suture.Service
subs []*subscription
nextSubscriptionIDs []int
nextGlobalID int
@@ -267,7 +265,6 @@ func NewLogger() Logger {
funcs: make(chan func(context.Context)),
toUnsubscribe: make(chan *subscription),
}
l.Service = util.AsService(l.serve, l.String())
// Make sure the timer is in the stopped state and hasn't fired anything
// into the channel.
if !l.timeout.Stop() {
@@ -276,7 +273,7 @@ func NewLogger() Logger {
return l
}
func (l *logger) serve(ctx context.Context) {
func (l *logger) Serve(ctx context.Context) error {
loop:
for {
select {
@@ -302,6 +299,8 @@ loop:
for _, s := range l.subs {
close(s.events)
}
return nil
}
func (l *logger) Log(t EventType, data interface{}) {
@@ -535,7 +534,7 @@ type noopLogger struct{}
var NoopLogger Logger = &noopLogger{}
func (*noopLogger) Serve() {}
func (*noopLogger) Serve(ctx context.Context) error { return nil }
func (*noopLogger) Stop() {}