Documentation
¶
Index ¶
- Constants
- func NewConnection(conn *sql.DB) (*connection, error)
- func NewConnectionPool(dsn db.DSN) *connectionPool
- func NewLeasedConnection(pooledConnection PooledConnectionIfc, leaseKey int64) *leasedConnection
- func NewLeasedConnections() *leasedConnections
- func NewMySQLConnectionFactory() *db.DBConnectionFactory
- func NewPooledConnection(connection ConnectionIfc, connPool ConnectionPoolIfc) (*pooledConnection, error)
- func NewQuery(connection ConnectionIfc, sqlQuery SQLQueryIfc) (*query, error)
- func NewResult(res db.Result) *result
- func NewResultSet() *resultSet
- type ConnectionCommonIfc
- type ConnectionIfc
- type ConnectionPoolIfc
- type LeasedConnectionIfc
- type LeasedConnectionsIfc
- type PooledConnectionIfc
- type QueryIfc
- type ResultIfc
- type ResultRow
- type ResultRowIfc
- type ResultSetIfc
- type SQLQuery
- type SQLQueryIfc
Constants ¶
const DEFAULT_MAX_CONNECTIONS = 1
const DEFAULT_MAX_IDLE = 60
const DEFAULT_MIN_CONNECTIONS = 1
Variables ¶
This section is empty.
Functions ¶
func NewConnectionPool ¶
func NewConnectionPool(dsn db.DSN) *connectionPool
func NewLeasedConnection ¶
func NewLeasedConnection(pooledConnection PooledConnectionIfc, leaseKey int64) *leasedConnection
func NewLeasedConnections ¶
func NewLeasedConnections() *leasedConnections
func NewMySQLConnectionFactory ¶
func NewMySQLConnectionFactory() *db.DBConnectionFactory
func NewPooledConnection ¶
func NewPooledConnection(connection ConnectionIfc, connPool ConnectionPoolIfc) (*pooledConnection, error)
func NewQuery ¶
func NewQuery(connection ConnectionIfc, sqlQuery SQLQueryIfc) (*query, error)
Make a new one of these! Returns nil+error if there is any problem setting up the sqlQuery...!
func NewResultSet ¶
func NewResultSet() *resultSet
Types ¶
type ConnectionCommonIfc ¶
type ConnectionCommonIfc interface { InTransaction() bool Begin() error NewQuery(query SQLQueryIfc) (QueryIfc, error) Commit() error Rollback() error Exec(query SQLQueryIfc, args ...interface{}) (sql.Result, error) Query(query SQLQueryIfc, args ...interface{}) (*sql.Rows, error) QueryRow(query SQLQueryIfc, args ...interface{}) *sql.Row }
type ConnectionIfc ¶
type ConnectionIfc interface { IsConnected() bool ConnectionCommonIfc }
type ConnectionPoolIfc ¶
type ConnectionPoolIfc interface { // Embedded interface(s) startable.StartableIfc dep.DependencyInjectableIfc cfg.ConfigurableIfc // Our own interface GetConnection() (*leasedConnection, error) Release(leaseKey int64) error GetMaxIdle() int Close() error }
A Connection Pool to maintain a set of one or more persistent connections to a MySQL database
func ConnectionPoolFromIfc ¶
func ConnectionPoolFromIfc(i interface{}) (ConnectionPoolIfc, error)
type LeasedConnectionIfc ¶
type LeasedConnectionIfc interface { ConnectionCommonIfc Release() error }
type LeasedConnectionsIfc ¶
type LeasedConnectionsIfc interface { // Public interface GetLeaseForConnection(connection PooledConnectionIfc) *leasedConnection Release(leaseKey int64) bool // contains filtered or unexported methods }
type PooledConnectionIfc ¶
type PooledConnectionIfc interface { // Connections IsConnected() bool // Leasing IsLeased() bool MatchesLeaseKey(leaseKey int64) bool Lease(leaseKey int64) Release() error Touch() IsExpired() bool ConnectionCommonIfc }
TODO: Can we not inherit this interface from ConnectionIfc?
type QueryIfc ¶
type QueryIfc interface { Run(args ...interface{}) (*result, error) RunReturnValue(receiver interface{}, args ...interface{}) error RunReturnInt(args ...interface{}) (*int, error) RunReturnString(args ...interface{}) (*string, error) RunReturnOne(args ...interface{}) (*ResultRow, error) RunReturnAll(args ...interface{}) (*resultSet, error) RunReturnSome(max int, args ...interface{}) (*resultSet, error) }
type ResultRow ¶
type ResultRow struct {
// contains filtered or unexported fields
}
Exported structure with non-exported properties to prevent consumer from accessing directly
func NewResultRow ¶
func NewResultRow() *ResultRow
func (ResultRow) Fields ¶
Pluck the fields out of the result and just return them so that caller can iterate with Get()
func (ResultRow) Get ¶
func (r ResultRow) Get(field string) nullables.NullableIfc
Get the named field value as a nullable from this ResultRow Note: Defies "accept interfaces, return structs" convention to support multiple Nullable types
func (ResultRow) MarshalJSON ¶
type ResultRowIfc ¶
type ResultSetIfc ¶
type ResultSetIfc interface { // Embedded interface(s) it.IterableIfc // Our own interface Get(rowNum int) *ResultRow Len() int IsEmpty() bool Add(result ResultRowIfc) IsFinalized() bool Finalize() ToJson() (*string, error) }
type SQLQuery ¶
type SQLQuery struct {
// contains filtered or unexported fields
}
func NewSQLQuery ¶
func (*SQLQuery) Resolve ¶
Resolve this query object as a flat SQL statement ready for execution Supplied args are same as those that will be fed to a prepared statement. These can be used to hint our resolver here with macro tokens that will sub in the correct number of placeholders for prepared statements, etc.
Using Pointer Receiver because we we don't want the caller to have to dereference a pointer produced by NewSQLQuery().