-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.go
47 lines (38 loc) · 988 Bytes
/
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
package reg
type Options struct {
RequiredParams []string
OptionalParams []string
// SupportBatchProcessing, if true this Processor can be called with batches
SupportBatchProcessing bool
// EnforceBatchProcessing, if true this Processor can ONLY be called with batches
EnforceBatchProcessing bool
}
type Option func(*Options)
func RequiredParams(params ...string) Option {
return func(opts *Options) {
opts.RequiredParams = append(opts.RequiredParams, params...)
}
}
func OptionalParams(params ...string) Option {
return func(opts *Options) {
opts.OptionalParams = append(opts.OptionalParams, params...)
}
}
func SupportBatch() Option {
return func(opts *Options) {
opts.SupportBatchProcessing = true
}
}
func EnforceBatch() Option {
return func(opts *Options) {
opts.SupportBatchProcessing = true
opts.EnforceBatchProcessing = true
}
}
func GetOpts(options []Option) Options {
opts := Options{}
for _, o := range options {
o(&opts)
}
return opts
}