Skip to content

Commit

Permalink
Promot lifecycle manager close to an actual method
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Woodward committed May 16, 2019
1 parent e446c9b commit f704464
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lifecycle/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type CloseFunc func()
// until all are complete.
type Manager struct {
closerChan chan CloseFunc
Close CloseFunc
close CloseFunc
WG sync.WaitGroup
}

Expand Down Expand Up @@ -78,7 +78,7 @@ func NewManager(logger logging.Logger) Manager {
}()
return Manager{
closerChan: closerChan,
Close: func() {
close: func() {
shutdown <- struct{}{}
stopwg.Wait()
},
Expand Down Expand Up @@ -122,3 +122,10 @@ func (m *Manager) ManageLifecycle(initializerClosers ...InitializerCloser) {
m.ManageInitialization(ic)
}
}

// Close runs the stored close function function, which will shut down all of
// the items that have been queued for cleanup. Each item is cleaned up in
// parallel. Close will block until all items have been successfully cleaned up.
func (m *Manager) Close() {
m.close()
}

0 comments on commit f704464

Please sign in to comment.