lib/ur: Send unreported failures on shutdown (#7164)

This commit is contained in:
Simon Frei
2020-12-22 20:17:14 +01:00
committed by GitHub
parent 4bcc38cf63
commit a20a5f61f0
21 changed files with 296 additions and 206 deletions
+7 -7
View File
@@ -14,7 +14,7 @@ import (
"github.com/thejerf/suture/v4"
"github.com/syncthing/syncthing/lib/util"
"github.com/syncthing/syncthing/lib/svcutil"
)
type recv struct {
@@ -33,8 +33,8 @@ type Interface interface {
type cast struct {
*suture.Supervisor
name string
reader util.ServiceWithError
writer util.ServiceWithError
reader svcutil.ServiceWithError
writer svcutil.ServiceWithError
outbox chan recv
inbox chan []byte
stopped chan struct{}
@@ -45,7 +45,7 @@ type cast struct {
// methods to get a functional implementation of Interface.
func newCast(name string) *cast {
// Only log restarts in debug mode.
spec := util.SpecWithDebugLogger(l)
spec := svcutil.SpecWithDebugLogger(l)
// Don't retry too frenetically: an error to open a socket or
// whatever is usually something that is either permanent or takes
// a while to get solved...
@@ -58,7 +58,7 @@ func newCast(name string) *cast {
outbox: make(chan recv, 16),
stopped: make(chan struct{}),
}
util.OnSupervisorDone(c.Supervisor, func() { close(c.stopped) })
svcutil.OnSupervisorDone(c.Supervisor, func() { close(c.stopped) })
return c
}
@@ -72,8 +72,8 @@ func (c *cast) addWriter(svc func(ctx context.Context) error) {
c.Add(c.writer)
}
func (c *cast) createService(svc func(context.Context) error, suffix string) util.ServiceWithError {
return util.AsService(svc, fmt.Sprintf("%s/%s", c, suffix))
func (c *cast) createService(svc func(context.Context) error, suffix string) svcutil.ServiceWithError {
return svcutil.AsService(svc, fmt.Sprintf("%s/%s", c, suffix))
}
func (c *cast) String() string {