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 {
}
func (m *Manager) RunNonBlocking(ctx context.Context) error {
m.initLifetime()
err := m.init(ctx)
if err != nil {
return err
}
func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsAreReady) error {
go func() error {
m.initLifetime()
err := m.init(ctx)
if err != nil {
return err
}
err = m.startBlocking(ctx)
if err != nil {
return err
}
err = m.startBlocking(ctx)
if err != nil {
return err
}
err = m.wait(ctx)
if err != nil {
return err
}
readyChan <- ComponentsAreReady{}
err = m.shutdown(ctx)
if err != nil {
return err
}
err = m.wait(ctx)
if err != nil {
return err
}
err = m.shutdown(ctx)
if err != nil {
return err
}
return nil
}()
return nil
}