mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
vendor: Update github.com/thejerf/suture
This commit is contained in:
parent
b91ff430db
commit
21035b0c1a
5
vendor/github.com/thejerf/suture/messages.go
generated
vendored
5
vendor/github.com/thejerf/suture/messages.go
generated
vendored
@ -41,12 +41,13 @@ type serviceFailed struct {
|
|||||||
|
|
||||||
func (sf serviceFailed) isSupervisorMessage() {}
|
func (sf serviceFailed) isSupervisorMessage() {}
|
||||||
|
|
||||||
func (s *Supervisor) serviceEnded(id serviceID) {
|
func (s *Supervisor) serviceEnded(id serviceID, complete bool) {
|
||||||
s.sendControl(serviceEnded{id})
|
s.sendControl(serviceEnded{id, complete})
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceEnded struct {
|
type serviceEnded struct {
|
||||||
id serviceID
|
id serviceID
|
||||||
|
complete bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s serviceEnded) isSupervisorMessage() {}
|
func (s serviceEnded) isSupervisorMessage() {}
|
||||||
|
22
vendor/github.com/thejerf/suture/service.go
generated
vendored
22
vendor/github.com/thejerf/suture/service.go
generated
vendored
@ -58,8 +58,30 @@ If you implement the fmt.Stringer interface, that will be used.
|
|||||||
If you do not implement the fmt.Stringer interface, a default
|
If you do not implement the fmt.Stringer interface, a default
|
||||||
fmt.Sprintf("%#v") will be used.
|
fmt.Sprintf("%#v") will be used.
|
||||||
|
|
||||||
|
Optional Interface
|
||||||
|
|
||||||
|
Services may optionally implement IsCompletable, which allows a service
|
||||||
|
to indicate to a supervisor that it does not need to be restarted if
|
||||||
|
it has terminated.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
type Service interface {
|
type Service interface {
|
||||||
Serve()
|
Serve()
|
||||||
Stop()
|
Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
IsCompletable is an optionally-implementable interface that allows a service
|
||||||
|
to report to a supervisor that it does not need to be restarted because it
|
||||||
|
has terminated normally. When a Service is going to be restarted, the
|
||||||
|
supervisor will check for this method, and if Complete returns true, the
|
||||||
|
service is removed from the supervisor instead of restarted.
|
||||||
|
|
||||||
|
This is only executed when the service is not running because it has
|
||||||
|
terminated, and has not yet been restarted.
|
||||||
|
|
||||||
|
*/
|
||||||
|
type IsCompletable interface {
|
||||||
|
Complete() bool
|
||||||
|
}
|
||||||
|
18
vendor/github.com/thejerf/suture/supervisor.go
generated
vendored
18
vendor/github.com/thejerf/suture/supervisor.go
generated
vendored
@ -403,8 +403,15 @@ func (s *Supervisor) Serve() {
|
|||||||
case serviceEnded:
|
case serviceEnded:
|
||||||
service, monitored := s.services[msg.id]
|
service, monitored := s.services[msg.id]
|
||||||
if monitored {
|
if monitored {
|
||||||
|
if msg.complete {
|
||||||
|
delete(s.services, msg.id)
|
||||||
|
go func() {
|
||||||
|
service.Service.Stop()
|
||||||
|
}()
|
||||||
|
} else {
|
||||||
s.handleFailedService(msg.id, fmt.Sprintf("%s returned unexpectedly", service), []byte("[unknown stack trace]"))
|
s.handleFailedService(msg.id, fmt.Sprintf("%s returned unexpectedly", service), []byte("[unknown stack trace]"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case addService:
|
case addService:
|
||||||
id := s.serviceCounter
|
id := s.serviceCounter
|
||||||
s.serviceCounter++
|
s.serviceCounter++
|
||||||
@ -524,7 +531,12 @@ func (s *Supervisor) runService(service Service, id serviceID) {
|
|||||||
|
|
||||||
service.Serve()
|
service.Serve()
|
||||||
|
|
||||||
s.serviceEnded(id)
|
complete := false
|
||||||
|
if completable, ok := service.(IsCompletable); ok && completable.Complete() {
|
||||||
|
complete = true
|
||||||
|
}
|
||||||
|
|
||||||
|
s.serviceEnded(id, complete)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,10 +546,10 @@ func (s *Supervisor) removeService(id serviceID, notificationChan chan struct{},
|
|||||||
delete(s.services, id)
|
delete(s.services, id)
|
||||||
s.servicesShuttingDown[id] = namedService
|
s.servicesShuttingDown[id] = namedService
|
||||||
go func() {
|
go func() {
|
||||||
successChan := make(chan bool)
|
successChan := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
namedService.Service.Stop()
|
namedService.Service.Stop()
|
||||||
successChan <- true
|
close(successChan)
|
||||||
if notificationChan != nil {
|
if notificationChan != nil {
|
||||||
notificationChan <- struct{}{}
|
notificationChan <- struct{}{}
|
||||||
}
|
}
|
||||||
|
2
vendor/manifest
vendored
2
vendor/manifest
vendored
@ -476,7 +476,7 @@
|
|||||||
"importpath": "github.com/thejerf/suture",
|
"importpath": "github.com/thejerf/suture",
|
||||||
"repository": "https://github.com/thejerf/suture",
|
"repository": "https://github.com/thejerf/suture",
|
||||||
"vcs": "git",
|
"vcs": "git",
|
||||||
"revision": "87e298c9891673c9ae76e10c2c9be589127e5f49",
|
"revision": "3f1fb62fe0a3cc6429122d7dc45588a8b59c5bb6",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user