Documentation ¶
Index ¶
- func Driver(driver driver.Driver, intr Interceptor) driver.Driver
- type Interceptor
- type NullInterceptor
- func (NullInterceptor) ConnBeginTx(ctx context.Context, conn driver.ConnBeginTx, txOpts driver.TxOptions) (context.Context, driver.Tx, error)
- func (NullInterceptor) ConnExecContext(ctx context.Context, conn driver.ExecerContext, query string, ...) (driver.Result, error)
- func (NullInterceptor) ConnPing(ctx context.Context, conn driver.Pinger) error
- func (NullInterceptor) ConnPrepareContext(ctx context.Context, conn driver.ConnPrepareContext, query string) (context.Context, driver.Stmt, error)
- func (NullInterceptor) ConnQueryContext(ctx context.Context, conn driver.QueryerContext, query string, ...) (context.Context, driver.Rows, error)
- func (NullInterceptor) ConnectorConnect(ctx context.Context, connect driver.Connector) (driver.Conn, error)
- func (NullInterceptor) ResultLastInsertId(res driver.Result) (int64, error)
- func (NullInterceptor) ResultRowsAffected(res driver.Result) (int64, error)
- func (NullInterceptor) RowsClose(ctx context.Context, rows driver.Rows) error
- func (NullInterceptor) RowsNext(ctx context.Context, rows driver.Rows, dest []driver.Value) error
- func (NullInterceptor) StmtClose(ctx context.Context, stmt driver.Stmt) error
- func (NullInterceptor) StmtExecContext(ctx context.Context, stmt driver.StmtExecContext, _ string, ...) (driver.Result, error)
- func (NullInterceptor) StmtQueryContext(ctx context.Context, stmt driver.StmtQueryContext, _ string, ...) (context.Context, driver.Rows, error)
- func (NullInterceptor) TxCommit(ctx context.Context, tx driver.Tx) error
- func (NullInterceptor) TxRollback(ctx context.Context, tx driver.Tx) error
- type RowsUnwrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Driver ¶
func Driver(driver driver.Driver, intr Interceptor) driver.Driver
Driver returns the supplied driver.Driver with a new object that has all of its calls intercepted by the supplied Interceptor object.
Important note: Seeing as the context passed into the various instrumentation calls this package calls, Any call without a context passed will not be intercepted. Please be sure to use the ___Context() and BeginTx() function calls added in Go 1.8 instead of the older calls which do not accept a context.
Types ¶
type Interceptor ¶
type Interceptor interface { // Connection interceptors ConnBeginTx(context.Context, driver.ConnBeginTx, driver.TxOptions) (context.Context, driver.Tx, error) ConnPrepareContext(context.Context, driver.ConnPrepareContext, string) (context.Context, driver.Stmt, error) ConnPing(context.Context, driver.Pinger) error ConnExecContext(context.Context, driver.ExecerContext, string, []driver.NamedValue) (driver.Result, error) ConnQueryContext(context.Context, driver.QueryerContext, string, []driver.NamedValue) (context.Context, driver.Rows, error) // Connector interceptors ConnectorConnect(context.Context, driver.Connector) (driver.Conn, error) // Results interceptors ResultLastInsertId(driver.Result) (int64, error) ResultRowsAffected(driver.Result) (int64, error) // Rows interceptors RowsNext(context.Context, driver.Rows, []driver.Value) error RowsClose(context.Context, driver.Rows) error // Stmt interceptors StmtExecContext(context.Context, driver.StmtExecContext, string, []driver.NamedValue) (driver.Result, error) StmtQueryContext(context.Context, driver.StmtQueryContext, string, []driver.NamedValue) (context.Context, driver.Rows, error) StmtClose(context.Context, driver.Stmt) error // Tx interceptors TxCommit(context.Context, driver.Tx) error TxRollback(context.Context, driver.Tx) error }
type NullInterceptor ¶
type NullInterceptor struct{}
NullInterceptor is a complete passthrough interceptor that implements every method of the Interceptor interface and performs no additional logic. Users should Embed it in their own interceptor so that they only need to define the specific functions they are interested in intercepting.
func (NullInterceptor) ConnBeginTx ¶
func (NullInterceptor) ConnExecContext ¶
func (NullInterceptor) ConnExecContext(ctx context.Context, conn driver.ExecerContext, query string, args []driver.NamedValue) (driver.Result, error)
func (NullInterceptor) ConnPrepareContext ¶
func (NullInterceptor) ConnQueryContext ¶
func (NullInterceptor) ConnQueryContext(ctx context.Context, conn driver.QueryerContext, query string, args []driver.NamedValue) (context.Context, driver.Rows, error)
func (NullInterceptor) ConnectorConnect ¶
func (NullInterceptor) ResultLastInsertId ¶
func (NullInterceptor) ResultLastInsertId(res driver.Result) (int64, error)
func (NullInterceptor) ResultRowsAffected ¶
func (NullInterceptor) ResultRowsAffected(res driver.Result) (int64, error)
func (NullInterceptor) StmtExecContext ¶
func (NullInterceptor) StmtExecContext(ctx context.Context, stmt driver.StmtExecContext, _ string, args []driver.NamedValue) (driver.Result, error)
func (NullInterceptor) StmtQueryContext ¶
func (NullInterceptor) StmtQueryContext(ctx context.Context, stmt driver.StmtQueryContext, _ string, args []driver.NamedValue) (context.Context, driver.Rows, error)
func (NullInterceptor) TxRollback ¶
type RowsUnwrapper ¶
RowsUnwrapper must be used by any middleware that provides its own wrapping for driver.Rows. Unwrap should return the original driver.Rows the middleware received. You may wish to wrap the driver.Rows returned by the Query methods if you want to pass extra information from the Query call to the subsequent RowsNext and RowsClose calls.
sqlmw needs to retrieve the original driver.Rows in order to determine the original set of optional methods supported by the driver.Rows of the database driver in use by the caller.
If a middleware returns a custom driver.Rows, the custom implmentation must support all the driver.Rows optional interfaces that are supported by by the drivers that will be used with it. To support any arbitrary driver all the optional methods must be supported.