goshutdowner

package module
v0.0.0-...-773db80 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 5 Imported by: 1

README

go-shutdowner

A simple library for graceful shutdowns

100% covered with unit tests.

See and try the example in /example to see the how things should be done.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ShutdownFunc

type ShutdownFunc func()

type Shutdowner

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

Simple struct, use like a sync.Mutex

 var s goshutdowner.Shutdowner
 s.Add(func() {
	 log.Println("Shutting down")
 })

func (*Shutdowner) Add

func (s *Shutdowner) Add(f ShutdownFunc)

Add a func, that should be called with s.Shutdown() or when receiving a shutdown signal

func (*Shutdowner) Shutdown

func (s *Shutdowner) Shutdown()

Trigger shutdown directly

func (*Shutdowner) ShutdownAndWait

func (s *Shutdowner) ShutdownAndWait()

Shutdown and wait till shutdown finished. Shorthand for:

s.Shutdown()
s.Wait()

func (*Shutdowner) Wait

func (s *Shutdowner) Wait()

Wait till all functions finished

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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