ext: add CleanAll() utility functions

master
Jimmy Zelinskie 5 years ago
parent e16d17dda9
commit 25078ac838

@ -86,3 +86,11 @@ func Appenders() map[string]Appender {
return ret
}
// CleanAll is a utility function that calls Clean() on every registered
// Appender.
func CleanAll() {
for _, appender := range Appenders() {
appender.Clean()
}
}

@ -93,3 +93,11 @@ func ListUpdaters() []string {
}
return r
}
// CleanAll is a utility function that calls Clean() on every registered
// Updater.
func CleanAll() {
for _, updater := range Updaters() {
updater.Clean()
}
}

@ -1,4 +1,4 @@
// Copyright 2017 clair authors
// Copyright 2019 clair authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -91,13 +91,8 @@ func RunUpdater(config *UpdaterConfig, datastore database.Datastore, st *stopper
// Clean up any resources the updater left behind.
defer func() {
for _, appenders := range vulnmdsrc.Appenders() {
appenders.Clean()
}
for _, updaters := range vulnsrc.Updaters() {
updaters.Clean()
}
vulnmdsrc.CleanAll()
vulnsrc.CleanAll()
log.Info("updater service stopped")
}()

Loading…
Cancel
Save