runner

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package runner helps run applications using a set of defaults that make it easier to handle interrupts and shutdowns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

A Group keeps track of a set of things to run. Example:

g := new(Group)
g.Start(func(ctx context.Context) error {
  // start up services
})
g.Stop(func(ctx context.Context) error {
  // stop services
})
if err := g.Wait(); err != nil {
  // so something with error
}

func (*Group) Start

func (g *Group) Start(f ...RunFunc)

Start adds a function to the group that will be called during startup.

func (*Group) Stop

func (g *Group) Stop(f ...RunFunc)

Stop adds a function to the group that will be called during shutdown.

func (*Group) Wait

func (g *Group) Wait() error

Wait will first run all the start methods, then wait for a signal to shutdown, and finally run all the stop methods.

type RunFunc

type RunFunc func(ctx context.Context) error

RunFunc defines a function to run with a context.

Jump to

Keyboard shortcuts

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