Files
opencloud/vendor/github.com/thejerf/suture/v4/messages.go
dependabot[bot] 24d1fe7c53 build(deps): bump github.com/thejerf/suture/v4 from 4.0.2 to 4.0.5
Bumps [github.com/thejerf/suture/v4](https://github.com/thejerf/suture) from 4.0.2 to 4.0.5.
- [Commits](https://github.com/thejerf/suture/compare/v4.0.2...v4.0.5)

---
updated-dependencies:
- dependency-name: github.com/thejerf/suture/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-18 09:55:19 +01:00

84 lines
1.5 KiB
Go

package suture
// sum type pattern for type-safe message passing; see
// http://www.jerf.org/iri/post/2917
type supervisorMessage interface {
isSupervisorMessage()
}
type listServices struct {
c chan []Service
}
func (ls listServices) isSupervisorMessage() {}
type removeService struct {
id serviceID
notification chan struct{}
}
func (rs removeService) isSupervisorMessage() {}
func (s *Supervisor) sync() {
select {
case s.control <- syncSupervisor{}:
case <-s.liveness:
}
}
type syncSupervisor struct {
}
func (ss syncSupervisor) isSupervisorMessage() {}
func (s *Supervisor) fail(id serviceID, panicVal interface{}, stacktrace []byte) {
select {
case s.control <- serviceFailed{id, panicVal, stacktrace}:
case <-s.liveness:
}
}
type serviceFailed struct {
id serviceID
panicVal interface{}
stacktrace []byte
}
func (sf serviceFailed) isSupervisorMessage() {}
func (s *Supervisor) serviceEnded(id serviceID, err error) {
s.sendControl(serviceEnded{id, err})
}
type serviceEnded struct {
id serviceID
err error
}
func (s serviceEnded) isSupervisorMessage() {}
// added by the Add() method
type addService struct {
service Service
name string
response chan serviceID
}
func (as addService) isSupervisorMessage() {}
type stopSupervisor struct {
done chan UnstoppedServiceReport
}
func (ss stopSupervisor) isSupervisorMessage() {}
func (s *Supervisor) panic() {
s.control <- panicSupervisor{}
}
type panicSupervisor struct {
}
func (ps panicSupervisor) isSupervisorMessage() {}