components signal

This commit is contained in:
Kasper Juul Hermansen 2022-09-21 21:45:48 +02:00
parent eb66692b47
commit f9109382cb
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -33,27 +33,32 @@ func NewManager() *Manager {
type ComponentsAreReady struct { type ComponentsAreReady struct {
} }
func (m *Manager) RunNonBlocking(ctx context.Context) error { func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsAreReady) error {
m.initLifetime() go func() error {
err := m.init(ctx) m.initLifetime()
if err != nil { err := m.init(ctx)
return err if err != nil {
} return err
}
err = m.startBlocking(ctx) err = m.startBlocking(ctx)
if err != nil { if err != nil {
return err return err
} }
err = m.wait(ctx) readyChan <- ComponentsAreReady{}
if err != nil {
return err
}
err = m.shutdown(ctx) err = m.wait(ctx)
if err != nil { if err != nil {
return err return err
} }
err = m.shutdown(ctx)
if err != nil {
return err
}
return nil
}()
return nil return nil
} }