-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
options.go
42 lines (35 loc) · 1.04 KB
/
options.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
package sqlcon
import "github.com/pborman/uuid"
type options struct {
UseTracedDriver bool
OmitArgs bool
AllowRoot bool
forcedDriverName string
}
// Opt is a wrapper for options.
type Opt func(*options)
// WithDistributedTracing will make it so that a wrapped driver is used that supports the opentracing API.
func WithDistributedTracing() Opt {
return func(o *options) {
o.UseTracedDriver = true
}
}
// WithOmitArgsFromTraceSpans will make it so that query arguments are omitted from tracing spans.
func WithOmitArgsFromTraceSpans() Opt {
return func(o *options) {
o.OmitArgs = true
}
}
// WithAllowRoot will make it so that root spans will be created if a trace could not be found using
// opentracing's SpanFromContext method.
func WithAllowRoot() Opt {
return func(o *options) {
o.AllowRoot = true
}
}
// WithRandomDriverName is specifically for writing tests as you can't register a driver with the same name more than once.
func WithRandomDriverName() Opt {
return func(o *options) {
o.forcedDriverName = uuid.New()
}
}