async

package
v2.0.0-...-fe6a7a6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 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

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

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

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

Types

type AsyncOption

type AsyncOption func(*asyncOptions)

func WithPoolName

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

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

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