/
options.go
executable file
·52 lines (44 loc) · 1.05 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
package main
import (
"github.com/joaosoft/logger"
"github.com/joaosoft/manager"
)
// DependencyOption ...
type DependencyOption func(builder *Dependency)
// Reconfigure ...
func (d *Dependency) Reconfigure(options ...DependencyOption) {
for _, option := range options {
option(d)
}
}
// WithConfiguration ...
func WithConfiguration(config *DependencyConfig) DependencyOption {
return func(builder *Dependency) {
builder.config = config
}
}
// WithLogger ...
func WithLogger(logger logger.ILogger) DependencyOption {
return func(builder *Dependency) {
builder.logger = logger
builder.isLogExternal = true
}
}
// WithLogLevel ...
func WithLogLevel(level logger.Level) DependencyOption {
return func(builder *Dependency) {
builder.logger.SetLevel(level)
}
}
// WithManager ...
func WithManager(mgr *manager.Manager) DependencyOption {
return func(builder *Dependency) {
builder.pm = mgr
}
}
// WithProtocol ...
func WithProtocol(protocol Protocol) DependencyOption {
return func(builder *Dependency) {
builder.vcs.protocol = protocol
}
}