async

package
v2.5.8 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Safe way to execute `go routine` without crashing the parent process while having a `panic`.

Index

Constants

This section is empty.

Variables

View Source
var ErrTaskTimeout = fmt.Errorf("task execution timeout")

Functions

func CaptureException added in v2.0.3

func CaptureException(c context.Context, err error)

func Execute

func Execute(fn func(), poolName ...string)

Execute provides a safe way to execute a function asynchronously without any context, recovering if they panic and provides all error stack aiming to facilitate fail causes discovery.

func ExecuteContext added in v2.4.0

func ExecuteContext(ctx context.Context, fn TaskWithCtx, asyncOpts ...AsyncOption) error

ExecuteWithContext execute a function returning an error asynchronously with a starndard context (not echo context), recovering if they panic.

func ExecuteWithContext

func ExecuteWithContext(fn Task, c echo.Context, poolName ...string)

ExecuteWithContext provides a safe way to execute a function asynchronously with a context, recovering if they panic and provides all error stack aiming to facilitate fail causes discovery.

func ExecuteWithTimeout added in v2.0.3

func ExecuteWithTimeout(ctx context.Context, duration time.Duration, fn TaskWithCtx, poolName ...string)

Types

type AsyncOption added in v2.4.0

type AsyncOption func(*asyncOptions)

func WithPoolName added in v2.4.0

func WithPoolName(poolName string) AsyncOption

WithPoolName sets the pool name for the async task. If the pool name is not provided, the default pool will be used.

func WithTimeout added in v2.4.0

func WithTimeout(d time.Duration) AsyncOption

WithTimeout sets the timeout for the async task. If the timeout is not provided, the task will run without a timeout.

type Task

type Task func(c context.Context)

type TaskWithCtx added in v2.4.0

type TaskWithCtx func(c context.Context) error

Jump to

Keyboard shortcuts

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