Documentation
¶
Overview ¶
WILL BE DEPRECATED WHEN TRACING IS MOVED TO A SEPARATE PACAKGE THIS IS HERE TO AVOID CIRCULAR DEPENDENCIES
Index ¶
- type DB
- func DBWarpper(db *sql.DB, t Trx, name string, logger *zap.Logger) DB
- func New(Driver string, DSN string) DB
- func NewWithOptions(Driver string, DSN string, opts *Options) DB
- func TracedNativeDBWrapper(Driver string, DSN string, t Trx, name string) DB
- func TracedNativeDBWrapperWithOptions(Driver string, DSN string, t *tracer.AppInsightsCore, name string, ...) DB
- type Hook
- type Options
- type Trx
- type Tx
- func (t *Tx) Commit() error
- func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (t *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (t *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (t *Tx) Rollback() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface {
Begin() (*Tx, error)
BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
Close() error
Conn(ctx context.Context) (*sql.Conn, error)
Exec(query string, args ...any) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
Ping() error
PingContext(ctx context.Context) error
Prepare(query string) (*sql.Stmt, error)
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
Query(query string, args ...any) (*sql.Rows, error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
SetConnMaxIdleTime(d time.Duration)
SetConnMaxLifetime(d time.Duration)
Stats() sql.DBStats
WithHook(h Hook)
SetMaxIdleConns(n int)
SetMaxOpenConns(n int)
}
func New ¶ added in v0.4.5
New returns a NativeDatabase interface for the given driver and DSN WARNING: It will panic if the driver is not supported
func NewWithOptions ¶ added in v0.4.5
New returns a NativeDatabase interface for the given driver and DSN WARNING: It will panic if the driver is not supported
func TracedNativeDBWrapper ¶
TracedNativeDBWrapper returns a DB interface for the given driver and DSN WARNING: It will panic if the driver is not supported DEPRECATED: Use New Or NewWithOptions instead
func TracedNativeDBWrapperWithOptions ¶ added in v0.4.1
func TracedNativeDBWrapperWithOptions( Driver string, DSN string, t *tracer.AppInsightsCore, name string, opts *Options, ) DB
TracedNativeDBWrapperWithOptions returns a DB interface for the given driver and DSN WARNING: It will panic if the driver is not supported
type Hook ¶ added in v0.5.4
type Hook interface {
AfterQuery(
context context.Context,
sid string,
method string,
query string,
args []interface{},
start_time time.Time,
end_time time.Time,
err error,
)
AfterBegin(
context context.Context,
sid string,
start_time,
end_time time.Time,
err error,
)
AfterCommit(
context context.Context,
sid string,
start_time,
end_time time.Time,
err error,
)
AfterRollback(
context context.Context,
start_time, end_time time.Time,
err error,
)
}
type Trx ¶ added in v0.4.5
type Trx interface {
TraceDependency(
ctx context.Context,
spanId string,
dependencyType string,
serviceName string,
commandName string,
success bool,
startTimestamp time.Time,
eventTimestamp time.Time,
fields map[string]string,
)
TraceException(
ctx context.Context,
err interface{},
skip int,
fields map[string]string,
)
}
type Tx ¶
func (*Tx) ExecContext ¶
func (t *Tx) ExecContext( ctx context.Context, query string, args ...interface{}, ) (sql.Result, error)
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query. params:
- query: query to execute
- args: arguments to pass to query
returns:
- sql.Result: result of query
- error: error if any
func (*Tx) QueryContext ¶
func (t *Tx) QueryContext( ctx context.Context, query string, args ...interface{}, ) (*sql.Rows, error)
QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query. params:
- ctx: context
- query: query to execute
- args: arguments to pass to query
returns:
- *sql.Rows: rows returned by query
- error: error if any
func (*Tx) QueryRowContext ¶
QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query. params:
- query: query to execute
- args: arguments to pass to query
returns:
- *sql.Row: row returned by query