background

package
v0.0.0-...-b14404a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package background implements functions to execute tasks in a separate goroutine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchExecN

func BatchExecN[T any](ctx context.Context, h func(ctx context.Context, v T) error, n int, vs ...T) error

Types

type Option

type Option[T any] struct {
	Handler    func(ctx context.Context, v T)
	MaxWorkers int
}

type Worker

type Worker[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](opt Option[T]) (*Worker[T], func())

New returns a new background manager.

func (*Worker[T]) BatchExec

func (w *Worker[T]) BatchExec(ctx context.Context, vs ...T)

func (*Worker[T]) Exec

func (w *Worker[T]) Exec(ctx context.Context, v T)

Exec sends a new message to the channel.

Jump to

Keyboard shortcuts

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