/
options.go
89 lines (70 loc) · 1.98 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package awsdapisqldriver
import (
"github.com/aws/aws-sdk-go/service/rdsdataservice/rdsdataserviceiface"
"gopkg.in/guregu/null.v4"
)
type Option interface {
apply(*options)
}
type options struct {
dataServiceApi rdsdataserviceiface.RDSDataServiceAPI
database null.String
resourceArn null.String
secretArn null.String
schema null.String
databaseType null.String
continueAfterTimeout null.Bool
}
type dataServiceApiOption struct {
DataServiceApi rdsdataserviceiface.RDSDataServiceAPI
}
type databaseOption string
type resourceArnOption string
type secretArnOption string
type schemaOption string
type databaseTypeOption string
type continueAfterTimeoutOption bool
func (c dataServiceApiOption) apply(opts *options) {
opts.dataServiceApi = c.DataServiceApi
}
func (c databaseOption) apply(opts *options) {
opts.database = null.StringFrom(string(c))
}
func (c resourceArnOption) apply(opts *options) {
opts.resourceArn = null.StringFrom(string(c))
}
func (c secretArnOption) apply(opts *options) {
opts.secretArn = null.StringFrom(string(c))
}
func (c schemaOption) apply(opts *options) {
opts.schema = null.StringFrom(string(c))
}
func (c databaseTypeOption) apply(opts *options) {
opts.databaseType = null.StringFrom(string(c))
}
func (c continueAfterTimeoutOption) apply(opts *options) {
opts.continueAfterTimeout = null.BoolFrom(bool(c))
}
func WithDataServiceApiOption(dataServiceApi rdsdataserviceiface.RDSDataServiceAPI) Option {
return dataServiceApiOption{
DataServiceApi: dataServiceApi,
}
}
func WithDatabase(c string) Option {
return databaseOption(c)
}
func WithResourceArn(c string) Option {
return resourceArnOption(c)
}
func WithSecretArn(c string) Option {
return secretArnOption(c)
}
func WithSchema(c string) Option {
return schemaOption(c)
}
func WithDatabaseType(c string) Option {
return databaseTypeOption(c)
}
func WithContinueAfterTimeout(c bool) Option {
return continueAfterTimeoutOption(c)
}