bg

package
v1.4.2-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bg tracks the process's fire-and-forget goroutines (a re-auth email, a close hook's push, a detached write) so shutdown can wait for them, bounded, instead of closing the database under them.

Index

Constants

This section is empty.

Variables

View Source
var Default = &Group{}

Default is the process-wide group; main waits on it at shutdown.

Functions

func Go

func Go(f func())

Go runs f on the Default group.

Types

type Group

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

Group counts running goroutines. It is a counter under a mutex rather than a sync.WaitGroup because a hook can start new work while shutdown is already waiting, and WaitGroup panics on an Add that races a Wait at zero.

func (*Group) Go

func (g *Group) Go(f func())

Go runs f in a goroutine the group waits for. Safe to call while Wait runs: the new goroutine is tracked too.

func (*Group) Wait

func (g *Group) Wait(timeout time.Duration) bool

Wait blocks until no goroutine started with Go is running, or timeout passes. It reports whether the group went idle.

Jump to

Keyboard shortcuts

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