graceful

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Logger *logger.Module
	// contains filtered or unexported fields
}

func (*Module) GetGracefulShutdownContext

func (m *Module) GetGracefulShutdownContext() context.Context

func (*Module) Init

func (m *Module) Init(c *service.Config)

Init the graceful module Usage: Wait should be called in the main function after Run

func main() {
  app := &App{}
  service.New(app).Run()
  app.Graceful.Wait()
}

func (*Module) Loop

func (m *Module) Loop(id string, interval time.Duration, fn func(time.Time))

Loop executes fn every `interval` until m.ctx is done (triggered by receiving a SIGTERM or SIGINT)

func (*Module) OnShutdown

func (m *Module) OnShutdown(shutdownFunc func(ctx context.Context))

OnShutdown is a helper to run a shutdownFunc when m.ctx is cancelled

func (*Module) Wait

func (m *Module) Wait()

Wait should be called at the top level of your app to block until the timeout completes.

Jump to

Keyboard shortcuts

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