Death Versions Save

Managing go application shutdown with signals.

v3.0.3

3 years ago

This release fixes a bug in the go.mod file and will now allow importing death v3 in a go modules project without pinning to a direct commit hash.

v3.0.2

3 years ago
  • Remove vendor folder and move to go.mod
  • Remove dependency on seelog for tests
  • update dependencies
  • update go version to 1.14 in travis

v3.0.1

5 years ago

Fixes gopkg import bug where deathlog was importing from master in the versioned gopkg.in import. Now death exists in a single package for import.

v3.0

5 years ago

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")
}

v2.0

6 years ago

This release encompasses a compatibility change for integrating with logrus. Logrus and seelog are incompatible loggers so we need a new major version in order to use one or the other.

Specifically this Logger interface that seelog uses:

type Logger interface {
	Error(v ...interface{}) error
	Debug(v ...interface{})
	Info(v ...interface{})
	Warn(v ...interface{}) error
}

is incompatible with the interface that logrus uses:

type Logger interface {
	Error(v ...interface{})
	Debug(v ...interface{})
	Info(v ...interface{})
	Warn(v ...interface{})
}

As such we need to version death depending on the logger you are using.

With this release you should be importing Death using gopkg.in with the version you want. See the Readme for more details on how to import the different versions.

This also contains a quality of life fix for the builder pattern with SetTimeout and SetLogger. Both of those functions will now return the death object so you can chain function calls.

v1.0

6 years ago

This release is for backwards compatibility based on using a logger subscribing to the following interface:

type Logger interface {
	Error(v ...interface{}) error
	Debug(v ...interface{})
	Info(v ...interface{})
	Warn(v ...interface{}) error
}

A popular logging library you can plugin here is https://github.com/cihub/seelog.