Documentation
¶
Index ¶
- func All[T any](fns ...func() T) []T
- func AllWithError[T any](fns ...func() (T, error)) ([]T, error)
- func ForEach[T any](items []T, concurrency int, fn func(T))
- func Go(fn func())
- func GoWithRecover(fn func(), recoverFn func(any))
- func Map[T, R any](items []T, fn func(T) R) []R
- func SetPanicHandler(handler func(any))
- type Result
- func NewResult[T any]() *Result[T]
- func Race[T any](fns ...func() T) *Result[T]
- func RaceWithTimeout[T any](timeout time.Duration, fns ...func() T) *Result[T]
- func Run[T any](fn func() T) *Result[T]
- func RunWithContext[T any](ctx context.Context, fn func() T) *Result[T]
- func RunWithTimeout[T any](timeout time.Duration, fn func() T) *Result[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllWithError ¶
AllWithError runs functions in parallel, returns first error
func GoWithRecover ¶
func GoWithRecover(fn func(), recoverFn func(any))
GoWithRecover executes with custom panic handler
func SetPanicHandler ¶
func SetPanicHandler(handler func(any))
SetPanicHandler sets a custom panic handler
Types ¶
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Result wraps an async operation's outcome
func RaceWithTimeout ¶
RaceWithTimeout returns first completed result or times out
func RunWithContext ¶
RunWithContext executes with context for cancellation
func RunWithTimeout ¶
RunWithTimeout executes with timeout
func (*Result[T]) GetOrDefault ¶
func (r *Result[T]) GetOrDefault(defaultValue T) T
GetOrDefault returns the value or a default if there's an error
Click to show internal directories.
Click to hide internal directories.