Documentation
¶
Overview ¶
Safe way to execute `go routine` without crashing the parent process while having a `panic`.
Index ¶
- Variables
- func CaptureException(c context.Context, err error)
- func Execute(fn func(), poolName ...string)
- func ExecuteContext(ctx context.Context, fn TaskWithCtx, asyncOpts ...AsyncOption) error
- func ExecuteWithContext(fn Task, c echo.Context, poolName ...string)
- func ExecuteWithTimeout(ctx context.Context, duration time.Duration, fn TaskWithCtx, ...)
- type AsyncOption
- type Task
- type TaskWithCtx
Constants ¶
This section is empty.
Variables ¶
var ErrTaskTimeout = fmt.Errorf("task execution timeout")
Functions ¶
func CaptureException ¶ added in v2.0.3
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 ¶
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
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.