An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 6.4% on proxy.golang.org
Top 5.5% forks on proxy.golang.org

proxy.golang.org : github.com/go-on/queue

Package queue allows streamlined error handling and piping of returned values. This package is considered stable and ready for production. It requires Go >= 1.1. Motivation: In go, sometimes you need to run a bunch of functions that return errors and/or results. You might end up writing stuff like this a lot of times. This is especially annoying if you want to handle all errors the same way (e.g. return the first error). This package provides a way to call functions in a queue while collecting the errors via a predefined or custom error handler. The predefined handler returns on the first error and custom error handlers might be used to catch/handle some/all kinds of errors while keeping the queue running. Usage: The functions in the queue are checked for the type of the last return value. If it is an error, the value will be checked when running the queue and the error handler is invoked if the error is not nil. The error handler decides, if it can handle the error and the run continues (by returning nil) or if it can't and the run stops (by returning an/the error). Custom error handlers must fullfill the ErrHandler interface. When running the queue, the return values of the previous function with be injected into the argument list of the next function at the position of the pseudo argument PIPE. However, if the last return value is an error, it will be omitted. There is also a different running mode invoked by the method Fallback() that runs the queue until the first function returns no error. A package with shortcuts that has a more compact syntax and is better includable with dot (.) is provided at github.com/go-on/queue/q

Registry - Source - Documentation - JSON - codemeta.json
purl: pkg:golang/github.com/go-on/queue
License: MIT
Latest release: almost 11 years ago
First release: almost 11 years ago
Namespace: github.com/go-on
Stars: 38 on
Forks: 3 on
Last synced: 30 days ago

    Loading...
    Readme
    Loading...