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,7 +33,8 @@ 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 {
go func() error {
m.initLifetime() m.initLifetime()
err := m.init(ctx) err := m.init(ctx)
if err != nil { if err != nil {
@ -45,6 +46,8 @@ func (m *Manager) RunNonBlocking(ctx context.Context) error {
return err return err
} }
readyChan <- ComponentsAreReady{}
err = m.wait(ctx) err = m.wait(ctx)
if err != nil { if err != nil {
return err return err
@ -55,6 +58,8 @@ func (m *Manager) RunNonBlocking(ctx context.Context) error {
return err return err
} }
return nil return nil
}()
return nil
} }
func (m *Manager) Run(ctx context.Context) error { func (m *Manager) Run(ctx context.Context) error {