safe_go

package
v1.2.29 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AntsInit

func AntsInit()

func AntsRunner

func AntsRunner(fns ...util.Func) error

func DryRun

func DryRun(fns ...util.Func) error

func Go added in v1.2.18

func Go(
	wg *sync.WaitGroup,
	ignoreRecover bool,
	doRecoverStack func(recoverTime time.Time, debugStack []byte),
	handler func(),
	catchHandler func(v ...any),
)

func Run

func Run(fns ...util.Func) error

func TaskConverter

func TaskConverter(fns ...util.Fn) []util.Func

Types

type Option

type Option func(r *Runner)

func WithContext

func WithContext(context context.Context) Option

func WithDeadlineCancel

func WithDeadlineCancel(deadline time.Time) Option

func WithErrCancel

func WithErrCancel() Option

func WithErrDryRun

func WithErrDryRun() Option

func WithLimit

func WithLimit(limit int) Option

func WithPanicRecover

func WithPanicRecover() Option

func WithProgressReport

func WithProgressReport(bar chan<- int) Option

func WithTimeoutCancel

func WithTimeoutCancel(timeout time.Duration) Option

type Runner

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

Runner

  • Runner
  • 1. context injection
  • 2. goroutine limit control
  • 3. error catch mode:
  • (1). one error cancel all: return error
  • (2). any error dry run: collect errors, return mergedError
  • (3). any panic recover: collect errors, return mergedError, collect stacktrace,
  • 4. timeout control
  • 5. progress report

func NewRunner

func NewRunner(tasks []util.Func, options ...Option) *Runner

func (*Runner) Error

func (r *Runner) Error() string

func (*Runner) Go

func (r *Runner) Go() *Runner

func (*Runner) Report added in v1.2.18

func (r *Runner) Report() string

Jump to

Keyboard shortcuts

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