-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
executable file
·45 lines (38 loc) · 894 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
package dbr_sync
import (
"github.com/joaosoft/logger"
"github.com/joaosoft/manager"
)
// DbrSyncOption ...
type DbrSyncOption func(dbrSync *DbrSync)
// Reconfigure ...
func (dbrSync *DbrSync) Reconfigure(options ...DbrSyncOption) {
for _, option := range options {
option(dbrSync)
}
}
// WithConfiguration ...
func WithConfiguration(config *DbrSyncConfig) DbrSyncOption {
return func(dbrSync *DbrSync) {
dbrSync.config = config
}
}
// WithLogger ...
func WithLogger(logger logger.ILogger) DbrSyncOption {
return func(dbrSync *DbrSync) {
dbrSync.logger = logger
dbrSync.isLogExternal = true
}
}
// WithLogLevel ...
func WithLogLevel(level logger.Level) DbrSyncOption {
return func(dbrSync *DbrSync) {
dbrSync.logger.SetLevel(level)
}
}
// WithManager ...
func WithManager(mgr *manager.Manager) DbrSyncOption {
return func(dbrSync *DbrSync) {
dbrSync.pm = mgr
}
}