forked from micro/go-micro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
46 lines (37 loc) · 827 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
46
package gomicro
import (
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/transport"
)
type Options struct {
Broker broker.Broker
Client client.Client
Server server.Server
Registry registry.Registry
Transport transport.Transport
}
func newOptions(opts ...Option) Options {
var opt Options
for _, o := range opts {
o(&opt)
}
if opt.Broker == nil {
opt.Broker = broker.DefaultBroker
}
if opt.Client == nil {
opt.Client = client.DefaultClient
}
if opt.Server == nil {
opt.Server = server.DefaultServer
}
if opt.Registry == nil {
opt.Registry = registry.DefaultRegistry
}
if opt.Transport == nil {
opt.Transport = transport.DefaultTransport
}
return opt
}