Documentation ¶
Overview ¶
Package pgwp contains a wrapper around sqlx for pooling.
The MIT License (MIT)
Copyright (c) 2016 Angel Del Castillo ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Variables
- type ConnectFunc
- type ExecFunc
- type Pool
- func (p *Pool) Close()
- func (p *Pool) Get(result interface{}, query string, args ...interface{}) error
- func (p *Pool) MustExec(query string, args ...interface{}) sql.Result
- func (p *Pool) Run(fn func(db *sqlx.DB) error) error
- func (p *Pool) Select(results interface{}, query string, args ...interface{}) error
- type QueryFunc
- type ResultErr
- type Worker
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConnectFunc ¶
ConnectFunc type is called when a new connection is required.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool type contains all workers with his respectives connections.
func Connect ¶
Connect handle sqlx.Connect function. Receives workers and queue size.
DEPRECATED. Use Open func.
func Open ¶
func Open(connectionFunc ConnectFunc, workers, queue int) (*Pool, error)
Open return a new pool. Receive a database connection function for later reuse.
workers define number of connections open to database. queue defines length channel for queries before block. It's useful for control over application demand.
type ResultErr ¶
type ResultErr struct {
Error error
}
ResultErr satisfies sql.Result
It's used when a timeout occurs
func (*ResultErr) LastInsertId ¶
LastInsertId satisfies sql.Result
func (*ResultErr) RowsAffected ¶
RowsAffected satisfies sql.Result