utils

package
v1.7.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package utils provides various utility functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyRunning is the error that is returned when runner is already running/closing/closed.
	ErrAlreadyRunning = errors.New("runner is already running/closing/closed")
	// ErrNotRunning is the error that is returned when runner is not running/closing/closed.
	ErrNotRunning = errors.New("runner is not running/closing/closed")
)

Functions

func UpdatePairSet

func UpdatePairSet[T comparable, H any](
	old []pair.Pair[T, H],
	toAdd []T,
	add func(T) (H, error),
	remove func(pair.Pair[T, H]) error,
) ([]pair.Pair[T, H], error)

UpdatePairSet updates a set of pairs. It removes pairs that are not in toAdd and adds pairs that are not in old.

Types

type Runner

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

Runner is a fn/stop runner.

func NewRunner

func NewRunner(fn, stop func() error, retryStop func(error) bool) *Runner

NewRunner creates a new runner.

func (*Runner) Run

func (r *Runner) Run() error

Run runs fn.

func (*Runner) Stop

func (r *Runner) Stop() error

Stop stops runner. It's safe to call even if runner is already stopped or in process of being stopped.

Jump to

Keyboard shortcuts

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