Documentation ¶
Index ¶
- Variables
- type DB
- type DBOption
- func WithDB(v DB) DBOption
- func WithDBDSN(v string) DBOption
- func WithDBDb(v *sqlx.DB) DBOption
- func WithDBDriverName(v string) DBOption
- func WithDBDriverPackage(v string) DBOption
- func WithDBLogger(v *slog.Logger) DBOption
- func WithDBOpts(v struct{ ... }) DBOption
- func WithDistributedTracing() DBOption
- func WithOmitArgsFromTraceSpans() DBOption
- func WithRandomDriverName() DBOption
- func WithTraceOrphans() DBOption
- type DBOptionFunc
- type EmptyDBOption
Constants ¶
This section is empty.
Variables ¶
var (
ErrRegister = errors.New("register db driver")
)
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct { DSN string // contains filtered or unexported fields }
DB represents a connection to a SQL database.
func (*DB) ApplyOptions ¶
ApplyOptions call apply() for all options one by one
func (*DB) GetDatabase ¶
GetDatabase returns a database instance.
type DBOption ¶
type DBOption interface {
// contains filtered or unexported methods
}
A DBOption sets options.
func WithDBDriverName ¶ added in v1.2.99
WithDBDriverName sets driverName in DB.
func WithDBDriverPackage ¶ added in v1.2.99
WithDBDriverPackage sets driverPackage in DB.
func WithDBLogger ¶ added in v1.2.99
WithDBLogger sets logger in DB.
func WithDBOpts ¶ added in v1.2.99
func WithDBOpts(v struct { UseTracedDriver bool TraceOrphans bool OmitArgs bool ForcedDriverName string }) DBOption
WithDBOpts sets opts in DB. options
func WithDistributedTracing ¶
func WithDistributedTracing() DBOption
WithDistributedTracing will make it so that a wrapped driver is used that supports the opentracing API. Deprecated: remove trace options.
func WithOmitArgsFromTraceSpans ¶
func WithOmitArgsFromTraceSpans() DBOption
WithOmitArgsFromTraceSpans will make it so that query arguments are omitted from tracing spans. Deprecated: remove trace options.
func WithRandomDriverName ¶
func WithRandomDriverName() DBOption
WithRandomDriverName is specifically for writing tests as you can't register a driver with the same name more than once. Deprecated: remove trace options.
func WithTraceOrphans ¶
func WithTraceOrphans() DBOption
WithTraceOrphans will make it so that root spans will be created if a trace could not be found using opentracing's SpanFromContext method. Deprecated: remove trace options.
type DBOptionFunc ¶
type DBOptionFunc func(*DB)
DBOptionFunc wraps a function that modifies DB into an implementation of the DBOption interface.
type EmptyDBOption ¶
type EmptyDBOption struct{}
EmptyDBOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.