-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhook.go
49 lines (41 loc) · 2.43 KB
/
hook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sqlplus
import (
"context"
"database/sql/driver"
)
type (
Hook interface {
ConnectorHook
ConnHook
TxHook
StmtHook
}
ConnHook interface {
BeforeExecContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, string, []driver.NamedValue, error)
AfterExecContext(ctx context.Context, query string, args []driver.NamedValue, dr driver.Result, err error) (context.Context, driver.Result, error)
BeforeBeginTx(ctx context.Context, opts driver.TxOptions, err error) (context.Context, driver.TxOptions, error)
AfterBeginTx(ctx context.Context, opts driver.TxOptions, dt driver.Tx, err error) (context.Context, driver.Tx, error)
BeforeQueryContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, string, []driver.NamedValue, error)
AfterQueryContext(ctx context.Context, query string, args []driver.NamedValue, rows driver.Rows, err error) (context.Context, driver.Rows, error)
BeforePrepareContext(ctx context.Context, query string, err error) (context.Context, string, error)
AfterPrepareContext(ctx context.Context, query string, ds driver.Stmt, err error) (context.Context, driver.Stmt, error)
BeforeClose(ctx context.Context, err error) (context.Context, error)
AfterClose(ctx context.Context, err error) (context.Context, error)
}
ConnectorHook interface {
BeforeConnect(ctx context.Context, err error) (context.Context, error)
AfterConnect(ctx context.Context, dc driver.Conn, err error) (context.Context, driver.Conn, error)
}
TxHook interface {
BeforeCommit(ctx context.Context, err error) (context.Context, error)
AfterCommit(ctx context.Context, err error) (context.Context, error)
BeforeRollback(ctx context.Context, err error) (context.Context, error)
AfterRollback(ctx context.Context, err error) (context.Context, error)
}
StmtHook interface {
BeforeStmtQueryContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, []driver.NamedValue, error)
AfterStmtQueryContext(ctx context.Context, query string, args []driver.NamedValue, rows driver.Rows, err error) (context.Context, driver.Rows, error)
BeforeStmtExecContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, []driver.NamedValue, error)
AfterStmtExecContext(ctx context.Context, query string, args []driver.NamedValue, r driver.Result, err error) (context.Context, driver.Result, error)
}
)