forked from cryptopay-dev/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
69 lines (57 loc) · 1.13 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
package hermione
import (
"github.com/im-kulikov/hermione/logger"
"github.com/im-kulikov/hermione/logger/zap"
"github.com/im-kulikov/hermione/registry"
)
type Options struct {
Logger logger.Logger
Registry registry.Registry
Address string
Name string
Version string
}
type Option func(*Options)
var (
DefaultServiceName = "microservice"
DefaultVersion = "0.0.0"
DefaultAddress = "localhost:0"
DefaultLogger = zap.New()
)
func newOptions(opts ...Option) Options {
opt := Options{
Address: DefaultAddress,
Logger: DefaultLogger,
Name: DefaultServiceName,
Version: DefaultVersion,
}
for _, o := range opts {
o(&opt)
}
return opt
}
func Version(version string) Option {
return func(o *Options) {
o.Version = version
}
}
func Logger(logger logger.Logger) Option {
return func(o *Options) {
o.Logger = logger
}
}
func Registry(registry registry.Registry) Option {
return func(o *Options) {
o.Registry = registry
}
}
func Address(address string) Option {
return func(o *Options) {
o.Address = address
}
}
func Name(name string) Option {
return func(o *Options) {
o.Name = name
}
}