worker

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package worker provides a background worker pool for services that need periodic or deferred work (health checks, capacity reconciliation, event firing).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool manages background goroutines for service work.

func NewPool

func NewPool(ctx context.Context, lcCfg *lifecycle.Config) *Pool

NewPool creates a worker pool. Background workers stop when ctx is cancelled. lcCfg controls timing: when delays are disabled, intervals fire immediately.

func (*Pool) Cancel

func (p *Pool) Cancel(name string)

Cancel stops a specific named worker.

func (*Pool) ScheduleInterval

func (p *Pool) ScheduleInterval(name string, interval time.Duration, fn func()) func()

ScheduleInterval runs fn repeatedly at the given interval. In instant mode (lifecycle delays disabled), fn is called once immediately and not repeated. Returns a cancel function.

func (*Pool) ScheduleOnce

func (p *Pool) ScheduleOnce(name string, delay time.Duration, fn func()) func()

ScheduleOnce runs fn after a delay. In instant mode, fn runs immediately. Returns a cancel function.

func (*Pool) Shutdown

func (p *Pool) Shutdown()

Shutdown stops all workers and prevents new ones from being scheduled.

Jump to

Keyboard shortcuts

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