-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathoptions.go
68 lines (55 loc) · 1.99 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package oplog
import "github.com/hashicorp/go-dbw"
// GetOpts - iterate the inbound Options and return a struct
func GetOpts(opt ...Option) Options {
opts := getDefaultOptions()
for _, o := range opt {
if o != nil {
o(opts)
}
}
return opts
}
// Option - how Options are passed as arguments
type Option func(Options)
// Options = how options are represented
type Options map[string]interface{}
func getDefaultOptions() Options {
return Options{
optionWithFieldMaskPaths: []string{},
optionWithSetToNullPaths: []string{},
optionWithAggregateNames: false,
optionWithOperationOptions: []dbw.Option{},
}
}
const optionWithOperationOptions = "optionWithOptions"
// WithOperationOptions represents an optional set dbw.Options. (see the dbw
// package for more info on the options)
func WithOperationOptions(opt ...dbw.Option) Option {
return func(o Options) {
o[optionWithOperationOptions] = opt
}
}
const optionWithFieldMaskPaths = "optionWithFieldMaskPaths"
// WithFieldMaskPaths represents an optional set of symbolic field paths (for example: "f.a", "f.b.d") used
// to specify a subset of fields that should be updated. (see google.golang.org/genproto/protobuf/field_mask)
func WithFieldMaskPaths(fieldMaskPaths []string) Option {
return func(o Options) {
o[optionWithFieldMaskPaths] = fieldMaskPaths
}
}
const optionWithSetToNullPaths = "optionWithSetToNullPaths"
// WithSetToNullPaths represents an optional set of symbolic field paths (for example: "f.a", "f.b.d") used
// to specify a subset of fields that should be set to null. (see google.golang.org/genproto/protobuf/field_mask)
func WithSetToNullPaths(setToNullPaths []string) Option {
return func(o Options) {
o[optionWithSetToNullPaths] = setToNullPaths
}
}
const optionWithAggregateNames = "optionWithAggregateNames"
// WithAggregateNames enables/disables the use of multiple aggregate names for Ticketers
func WithAggregateNames(enabled bool) Option {
return func(o Options) {
o[optionWithAggregateNames] = enabled
}
}