life

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package life provides application wide context with cancel function and some helper functions to register syscalls for smooth app termination and reloading (conf, logger and such).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppContext

type AppContext struct {
	Context context.Context
	StopApp context.CancelFunc
}

AppContext represents application wide context with cancel function and some helper functions to register syscalls for smooth app termination and reloading (conf, logger and such)

func New

func New() AppContext

New prepares application wide context with cancel function and some helper functions to register syscalls for smooth app termination and reloading (conf, logger and such)

func (*AppContext) ByeTime

func (a *AppContext) ByeTime() bool

ByeTime is a helper that returns true if it's time for application to stop

func (*AppContext) RegisterReloaders

func (a *AppContext) RegisterReloaders(
	sig syscall.Signal, reloaders ...Reloader)

RegisterReloaders allows you to specify stuff you want to "reload" based on some signal (like reloading config, or rotating log file based on SIGHUP)

func (*AppContext) RegisterStopSignals

func (a *AppContext) RegisterStopSignals(dieTimeout time.Duration,
	signals ...syscall.Signal)

RegisterStopSignals handles signals that will terminate application After signal is received it cancels app wide context and waits specified interval before exiting

func (*AppContext) RunForever

func (a *AppContext) RunForever()

RunForever keeps main function running until there is a panic or kill signal NOTE: Call this directly from main, without go!

type Reloader

type Reloader interface {
	Reload()
}

Reloader interface ..

Jump to

Keyboard shortcuts

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