Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
47f249af82
|
|||
a59a278140
|
17
manager.go
17
manager.go
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -34,15 +33,10 @@ func NewManager() *Manager {
|
||||
type ComponentsAreReady struct {
|
||||
}
|
||||
|
||||
func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsAreReady) error {
|
||||
type CleanupFunc func(ctx context.Context) error
|
||||
|
||||
func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsAreReady) (CleanupFunc, error) {
|
||||
go func() error {
|
||||
defer func() {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
err := m.shutdown(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
m.initLifetime()
|
||||
err := m.init(ctx)
|
||||
if err != nil {
|
||||
@@ -63,7 +57,10 @@ func (m *Manager) RunNonBlocking(ctx context.Context, readyChan chan ComponentsA
|
||||
|
||||
return nil
|
||||
}()
|
||||
return nil
|
||||
|
||||
return func(ctx context.Context) error {
|
||||
return m.shutdown(ctx)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *Manager) Run(ctx context.Context) error {
|
||||
|
Reference in New Issue
Block a user