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