runner

package module
v0.0.0-...-8635b2a Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 9 Imported by: 3

README

Runner

Runs things.

  • Command works for CLI and Service Entry points, parsing cli flags and env vars
  • Rungroup is like errgroup but with logging so you can tell which service didn't exit

Lots more to come!

Documentation

Index

Constants

View Source
const (
	LogLineGroupStarted                         = "Run group triggered"
	LogLineGroupExited                          = "Run group exited"
	LogLineGroupExitedWithError                 = "Run group exited with error"
	LogLineRunnerStarted                        = "Runner started"
	LogLineRunnerExited                         = "Runner exited"
	LogLineRunnerExitedWithError                = "Runner exited with error"
	LogLineRunnerExitedWithContextCanceledError = "Runner exited with context canceled"
)

Variables

This section is empty.

Functions

func WithCancelOnSignals

func WithCancelOnSignals(signals ...os.Signal) option

WithCancelOnSignals will cancel the context when any of the given signals are received. If no signals are given, the default signals are used: os.Interrupt, os.Kill, syscall.SIGTERM

func WithLogger

func WithLogger(logger log.Logger) option

func WithName

func WithName(name string) option

Types

type Group

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

func NewGroup

func NewGroup(options ...option) *Group

func (*Group) Add

func (gg *Group) Add(name string, f func(ctx context.Context) error)

Add registers a function to run when the group is triggered with Run or Start. If the group is already running, the function will be started immediately and added to the pool.

func (*Group) Run

func (gg *Group) Run(ctx context.Context) error

Run runs the runners in the group until all have exited. If any function returns an error, the context passed to each is canceled. Once a group is triggered with Run, no more functions can be added

func (*Group) Start

func (gg *Group) Start(ctx context.Context) error

Start starts the runners in the group in the background. Errors are not returned until Wait is called Runners are tied to the passed in context

func (*Group) Wait

func (gg *Group) Wait() error

Wait waits for all runners to exit. If any runner returns an error, the first error is returned. Once Wait is called, no more runners can be added to the group

Directories

Path Synopsis
Package parallel provides a simpler version of errgroup where: - all goroutines are started immediately - no concurrency limit - runners receive a context - the context is canceled without passing 'cause'.
Package parallel provides a simpler version of errgroup where: - all goroutines are started immediately - no concurrency limit - runners receive a context - the context is canceled without passing 'cause'.

Jump to

Keyboard shortcuts

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