Ecosyste.ms: Packages

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

Top 6.2% on proxy.golang.org
Top 1.6% dependent packages on proxy.golang.org
Top 2.0% dependent repos on proxy.golang.org
Top 8.8% forks on proxy.golang.org

proxy.golang.org : github.com/go-mysql/errors

Package errors provides functions and variables for handling common MySQL errors. Common errors are: connection-related, duplicate key, and read-only. These should be explicitly handled to allow retrying when possible (connection and read-only errors) and returning a better error to the caller (duplicate key). Handling these errors directly is not trivial. It requires low-level knowledge and experience with sql/database, github.com/go-sql-driver/mysql, and MySQL. See the implementation of Lost, for example. More importantly: these are implementation details which should not be leaked to the caller. The caller usually only needs to know if the connection was lost or MySQL is read-only (so it wait and retry), or if there was a duplicate key error (which may be an error to the user or something the caller expects and handles). This packages makes handling these errors easy. See https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html for a complete list of MySQL server errors. The vast majority are rarely encountered in typical, well-behaved systems. Error and CanRetry are the most important functions in this package. They are used like: The example above tries N-many times to save an item into a database. It handles MySQL errors explicitly. On ErrDupeKey it does not retry, it returns HTTP 409 (status conflict). Else if the error is transient, it waits 1 second and retries. All other errors cause an HTTP 500 (internal server error) return.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/go-mysql/errors
Keywords: error-handling, mysql
License: GPL-3.0
Latest release: almost 6 years ago
First release: almost 6 years ago
Namespace: github.com/go-mysql
Dependent packages: 12
Dependent repositories: 7
Stars: 5 on GitHub
Forks: 4 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 15 days ago

    Loading...
    Readme
    Loading...