util

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package util adds additional utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ShutdownHandler

type ShutdownHandler func() error

ShutdownHandler is any function that has no parameters and can return an error.

Shutdown handlers are the last resort for the application when there is no more flow control in the user's hand.

Returned errors are logged.

func ShutdownFunc

func ShutdownFunc(fn func()) ShutdownHandler

ShutdownFunc wraps a function withot an error return type.

To make sure there are no silenced errors, panics are also recovered.

type ShutdownManager

type ShutdownManager struct {
	// contains filtered or unexported fields
}

ShutdownManager manages an application shutdown by calling the registered handlers.

func NewShutdownManager

func NewShutdownManager(errorHandler errors.Handler) *ShutdownManager

NewShutdownManager creates a new Shutdown manager.

func (*ShutdownManager) Register

func (sm *ShutdownManager) Register(handlers ...ShutdownHandler)

Register appends new shutdown handlers to the list of existing ones.

func (*ShutdownManager) RegisterAsFirst

func (sm *ShutdownManager) RegisterAsFirst(handlers ...ShutdownHandler)

RegisterAsFirst prepends new shutdown handlers to the list of existing ones.

func (*ShutdownManager) Shutdown

func (sm *ShutdownManager) Shutdown()

Shutdown is the panic recovery and shutdown handler.

It should be called as the last method in `main` (eg. using defer).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL