{"@context":"https://w3id.org/codemeta/3.0","@type":"SoftwareSourceCode","identifier":"pkg:golang/github.com/%21vivid%21cortex/dbcontrol","name":"github.com/VividCortex/dbcontrol","description":"Package dbcontrol limits the number of active connections for database/sql.\n\nImplementations of Go's database/sql package prior to Go 1.2, don't let the user\nput a limit on the number of active connections to the underlying DB.  If enough\nconcurrent requests are made, so that the package runs out of available\nconnections, then more are requested from the driver no matter how many you have\nat the pool already. Hence, unless you take precautions in your design/code, or\nthere's specific support from the actual DB driver you're using, you are likely\nto hit some other limit (DB engine itself, OS) or simply run out of resources.\n\nNone of those situations are desirable, of course. If you hit DB or OS limits on\nthe number of connections, then many of your statements will start failing cause\nno connection is available for them to use. You can get around it if you're\nlucky enough to have driver support, but then you are tied to a particular DB.\n\nThis package is a wrapper on Go's standard database/sql, providing a general\nmechanism so that you're free to use statements as usual, yet have the number of\nactive connections limited. A wrapper DB type is declared, that supports all\nstandard operations from database/sql. To use it, you should set the maximum\nnumber of connections you want to allow, just like:\n\nAll databases opened by the package afterwards will use a maximum of 10\nconnections. You can change this setting as often as you wish, but keep in mind\nthat the number is bound to databases as they are opened, i.e., changing this\nconcurrency setting has no effect on already-opened databases. Note also that\nyou can get the default non-limited behavior by setting concurrency to zero. To\nopen a DB you proceed just like with the database/sql package, like so:\n\nNote that sql.Row, sql.Rows and sql.Stmt types are overridden by this package,\nbut that's probably transparent unless you declare the types explicitly. If you\ndeclare variables using the := operator you'll be fine. Usage now follows the\nexpected pattern from database/sql:\n\nThe full set of features at database/sql is supported, including transactions,\neven though not all functions need to be overridden. This package was designed\nto provide the feature with minimum overhead, and thus uses knowledge of\ndatabase/sql internals to know when locking is required/appropriate. As an\nextension, you can set a channel to receive the locking duration each time a\nconnection has to be waited for. This can work as an aid to help you tune the\npool size or otherwise work around concurrency problems. You can also set a\nchannel where notifications will be sent every time a connection is held for\nlonger than a certain timeout. The notification includes the full stack trace of\nthe caller at the time the connection was requested. This can prove useful to\nidentify long-running queries that are locking connections, and possibly\nimpeding others from running. The feature can be turned on and off at will. A\nsmall performance penalty will be paid if on (that of retrieving the caller's\nstack), but none if the feature is off (the default).\n\nNote that only functions specific to this package or with altered semantics are\ndocumented. Please refer to the database/sql package documentation for more\ninformation.","version":"v1.0.0","softwareVersion":"v1.0.0","license":"https://spdx.org/licenses/MIT","codeRepository":"https://github.com/VividCortex/dbcontrol","issueTracker":"https://github.com/VividCortex/dbcontrol/issues","url":"https://github.com/VividCortex/dbcontrol","programmingLanguage":{"@type":"ComputerLanguage","name":"Go"},"dateCreated":"2021-04-26","dateModified":"2021-04-26","datePublished":"2021-04-26","copyrightYear":2021,"downloadUrl":"https://proxy.golang.org/github.com/!vivid!cortex/dbcontrol/@v/v1.0.0.zip","softwareHelp":{"@type":"WebSite","url":"https://pkg.go.dev/github.com/VividCortex/dbcontrol#section-documentation"},"applicationCategory":"go","runtimePlatform":"go","developmentStatus":"active","sameAs":["https://pkg.go.dev/github.com/VividCortex/dbcontrol"],"https://www.w3.org/ns/activitystreams#likes":29,"https://forgefed.org/ns#forks":4}