Release 3.0
This release removes all external dependencies to a logger. Now by default death will not log anything but supports using your own custom logger. To use the logger satisfy the deathlog.Logger interface.
Also included with this release is the ability to check for errors from the closers being closed. If death fails to close all the closers, or if several closers return an error, the errors will be concatenated and bubbled up to the caller of death.WaitForDeath(closers...)
. See the example below:
func main() {
death := DEATH.NewDeath(SYS.SIGINT, SYS.SIGTERM) //pass the signals you want to end your application
objects := make([]io.Closer, 0)
objects = append(objects, &NewType{}) // this will work as long as the type implements a Close method
//when you want to block for shutdown signals
err := death.WaitForDeath(objects...) // this will finish when a signal of your type is sent to your application
if err != nil {
log.Println(err)
os.Exit(1)
}
}
type NewType struct {
}
func (c *NewType) Close() error {
return fmt.Errorf("an error")
}