Documentation ¶
Index ¶
- func ErrToCode(err error) codes.Code
- func Register(driverName string, options ...Option) (string, error)
- func Wrap(dri driver.Driver, opts ...Option) driver.Driver
- func WrapConn(c driver.Conn, opts ...Option) driver.Conn
- func WrapConnector(dc driver.Connector, opts ...Option) driver.Connector
- type Event
- type Hook
- type Method
- type Option
- func WithDatabaase(name string) Option
- func WithHooks(hooks ...Hook) Option
- func WithInstance(name string) Option
- func WithLastInsertID(b bool) Option
- func WithOptions(options Options) Option
- func WithPing(b bool) Option
- func WithResetSession(b bool) Option
- func WithRowsAffected(b bool) Option
- func WithRowsClose(b bool) Option
- func WithRowsNext(b bool) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register initializes and registers our otsql wrapped database driver identified by its driverName and using provided Options. On success it returns the generated driverName to use when calling sql.Open. It is possible to register multiple wrappers for the same database driver if needing different Options for different connections.
Types ¶
type Method ¶
type Method string
var ( MethodPing Method = "ping" MethodExec Method = "exec" MethodQuery Method = "query" MethodPrepare Method = "prepare" MethodBegin Method = "begin" MethodCommit Method = "commit" MethodRollback Method = "rollback" MethodLastInsertId Method = "last_insert_id" MethodRowsAffected Method = "rows_affected" MethodRowsClose Method = "rows_close" MethodRowsNext Method = "rows_next" MethodCreateConn Method = "create_conn" MethodCloseConn Method = "close_conn" MethodResetSession Method = "reset_session" )
type Option ¶
type Option func(*Options)
Option allows for managing otsql configuration using functional options.
func WithDatabaase ¶
WithDatabase sets instance name, default parse from dsn when create conn.
func WithInstance ¶
WithInstance sets instance name, default parse from dsn when create conn.
func WithLastInsertID ¶
WithLastInsertID if set to true, will enable the hook of LastInsertId calls.
func WithOptions ¶
WithOptions sets our otsql options through a single Options object.
func WithResetSession ¶
WithResetSession if set to true, will enable the hook of ResetSession calls.
func WithRowsAffected ¶
WithRowsAffected if set to true, will enable the of RowsAffected calls.
func WithRowsClose ¶
WithRowsClose if set to true, will enable the of RowsClose calls.
func WithRowsNext ¶
WithRowsNext if set to true, will enable of RowsNext calls. This can result in many calls.
type Options ¶
type Options struct { // Instance, default parse from dsn. Instance string // Database, default parse from dsn. Database string // PingB, if set to true, will enable the hook of Ping requests. PingB bool // RowsAffectedB, if set to true, will enable the hook of RowsAffected calls. RowsAffectedB bool // LastInsertIdB, if set to true, will enable the hook LastInsertId calls. LastInsertIdB bool // RowsNextB, if set to true, will enable the hook of calls. // This can result in many calls. RowsNextB bool // RowsCloseB, if set to true, will enable the hook of RowsClose calls. RowsCloseB bool // ResetSessionB, if set to true, will enable the hook of ResetSession calls. ResetSessionB bool // Hooks, enabled hooks. Hooks []Hook }
Options holds configuration of our otsql hook. By default all options are set to false intentionally when creating a wrapped driver and provide the most sensible default with both performance and security in mind.