Documentation ¶
Overview ¶
Package dbhook implements database hooks
Index ¶
- Variables
- func Wrap(drv driver.Driver, hks Hook) driver.Driver
- type CallerType
- type Conn
- func (conn *Conn) Begin() (driver.Tx, error)
- func (conn *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (conn *Conn) CheckNamedValue(nv *driver.NamedValue) (err error)
- func (conn *Conn) Close() error
- func (conn *Conn) Prepare(query string) (driver.Stmt, error)
- func (conn *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- type Driver
- type ExecerContext
- type ExecerQueryer
- type ExecerQueryerSessionResetter
- type Hook
- type HookAfter
- type HookBefore
- type HookError
- type HookInput
- type HookOption
- type Hooks
- type QueryerContext
- type SessionResetter
- type Stmt
- func (stmt *Stmt) Close() error
- func (stmt *Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (stmt *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (stmt *Stmt) NumInput() int
- func (stmt *Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (stmt *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNonExecer = errors.New("ExecerContext created for a non Execer driver.Conn") ErrNonQueryer = errors.New("QueryerContext created for a non Queryer driver.Conn") ErrNonSessionResetter = errors.New("ResetSession created for a non SessionResetter driver.Conn") ErrNamedParametersNotSupport = errors.New("sql: driver does not support the use of Named Parameters") )
Functions ¶
Types ¶
type CallerType ¶
type CallerType string
const ( CallerStmt CallerType = "stmt" CallerStmtExec CallerType = "stmt_exec" CallerStmtQuery CallerType = "stmt_query" CallerExec CallerType = "exec" CallerQuery CallerType = "query" CallerBegin CallerType = "begin" CallerCommit CallerType = "commit" CallerRollback CallerType = "rollback" )
type Conn ¶
type Conn struct { Conn driver.Conn ConnBeginTx driver.ConnBeginTx // contains filtered or unexported fields }
func (*Conn) CheckNamedValue ¶ added in v0.3.0
func (conn *Conn) CheckNamedValue(nv *driver.NamedValue) (err error)
type ExecerContext ¶
type ExecerContext struct {
*Conn
}
func (*ExecerContext) ExecContext ¶
func (conn *ExecerContext) ExecContext( ctx context.Context, query string, args []driver.NamedValue, ) (driver.Result, error)
type ExecerQueryer ¶
type ExecerQueryer struct { *Conn *ExecerContext *QueryerContext }
type ExecerQueryerSessionResetter ¶
type ExecerQueryerSessionResetter struct { *Conn *ExecerContext *QueryerContext *SessionResetter }
type Hook ¶
type Hook interface { HookBefore HookAfter HookError }
type HookBefore ¶ added in v0.2.0
type HookInput ¶
type HookInput struct { Query string Error error Caller CallerType Args []driver.Value }
type HookOption ¶
type HookOption func(*Hooks)
func WithHook ¶ added in v0.2.0
func WithHook(hooks ...Hook) HookOption
func WithHooksAfter ¶
func WithHooksAfter(hooks ...HookAfter) HookOption
func WithHooksBefore ¶
func WithHooksBefore(hooks ...HookBefore) HookOption
func WithHooksError ¶
func WithHooksError(hooks ...HookError) HookOption
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func NewHooks ¶
func NewHooks(opts ...HookOption) *Hooks
type QueryerContext ¶
type QueryerContext struct {
*Conn
}
func (*QueryerContext) QueryContext ¶
func (conn *QueryerContext) QueryContext( ctx context.Context, query string, args []driver.NamedValue, ) (driver.Rows, error)
type SessionResetter ¶
type SessionResetter struct {
*Conn
}
func (*SessionResetter) ResetSession ¶
func (s *SessionResetter) ResetSession(ctx context.Context) error
type Stmt ¶
func (*Stmt) ExecContext ¶
ExecContext must honor the context timeout and return when it is canceled. nolint:dupl // it's ok
func (*Stmt) QueryContext ¶
QueryContext must honor the context timeout and return when it is canceled. nolint:dupl // it's ok
Source Files ¶
Click to show internal directories.
Click to hide internal directories.