Skip to content

New Feature: Fallback #6

@ghosind

Description

@ghosind

Fallback is a function that is expected to execute the functions in order until one of them succeeds (does not return an error). If all functions fail, it returns the error from the last function.

err := async.Fallback(
    func() error {
        // do something
        return errors.New("first error")
    },
    func() error {
        // do something else
        return nil // success
    },
    func() error {
        // this function will not be executed because the previous one succeeded
        return nil
    },
)
// err is nil

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions