Documentation
¶
Overview ¶
Package model encapsules db operations. Only for internal purpose.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBDrv ¶
type DBDrv interface {
// creates a notification to send
Create(i *Item) (err error)
// send a notification again, does not retry, return &E404{} if id not found
Resend(id string, max uint32) (err error)
// update a notification after sending. *NEVER* return error if id not found
Update(id string, tried uint32, next int64, state types.State, resp []byte) (err error)
// retrieve last sending result, return &E404{} if id not found
Result(id string) (ret []byte, err error)
// retrieve status, return &E404{} if id not found
Status(id string) (ret types.Status, err error)
// retrieve detail info, return &E404{} if id not found
Detail(id string) (ret types.Detail, err error)
// get one pending notification
Pending(now int64, max uint32, drvs, ids []string) (ret *Item, err error)
// delete a notification, excepts current sending notifications
// *NEVER* return error if nothing's deleted (id not found or something)
Delete(id string, cur []string) (err error)
// clear finished notifications older than t, excepts current sending ones
Clear(t time.Time, cur []string) (err error)
// clear all notifications older than t, excepts current sending ones
ForceClear(t time.Time, cur []string) (err error)
}
DBDrv defines db related methods
It is possible to do some magic in this interface to affect sender, but you *SHOULD NOT* do this unless you have good reason.
type DrvBase ¶
DrvBase is a helper to cache *sql.Stmt
func (*DrvBase) Prepare ¶
Prepare caches a *sql.Stmt
It supports error checking like this:
err = d.Prepare(query1, nil)
err = d.Prepare(query2, err)
err = d.Prepare(query3, err)
if err != nil {
return err
}
func (*DrvBase) Stmt ¶
Stmt retrieves previously cached *sql.Stmt, returns nil if not found
It is *RECOMMENDED* to store your sql query statement in constant or variable, and call Prepare()/Stmt() with that const/var. See package mysqldrv as a simple example, and package pgsqldrv for a even better example.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dbdrvtest provides needed integral test for db driver writer.
|
Package dbdrvtest provides needed integral test for db driver writer. |
|
Package mysqldrv provides mysql db driver This driver is tested with github.com/go-sql-driver/mysql against mysql 5.7/8
|
Package mysqldrv provides mysql db driver This driver is tested with github.com/go-sql-driver/mysql against mysql 5.7/8 |
|
Package pgsqldrv provides postgresql db driver This driver is tested with github.com/jackc/pgx/v4 against postgres 9~13
|
Package pgsqldrv provides postgresql db driver This driver is tested with github.com/jackc/pgx/v4 against postgres 9~13 |
Click to show internal directories.
Click to hide internal directories.