-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
60 lines (52 loc) · 1.25 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
package adaptiveservice
type conf struct {
lg Logger
registryAddr string
providerID string
scope Scope
qsize int
}
func newConf() *conf {
return &conf{
lg: LoggerNull{},
scope: ScopeAll,
qsize: 128,
}
}
// Option is option to be set.
type Option func(*conf)
// WithLogger sets the logger.
func WithLogger(lg Logger) Option {
return func(c *conf) {
c.lg = lg
}
}
// WithScope sets the publishing or discovering scope, which is
// an ORed value of ScopeProcess, ScopeOS, ScopeLAN or ScopeWAN.
// Default is ScopeAll.
func WithScope(scope Scope) Option {
return func(c *conf) {
c.scope = scope
}
}
// WithProviderID sets the provider ID which is used to identify service
// in the network where there are multiple publisher_service instances
// found in the registry.
// Provider ID is usually shared by servers in the same network node.
func WithProviderID(id string) Option {
return func(c *conf) {
c.providerID = id
}
}
// WithRegistryAddr sets the registry address in format ip:port.
func WithRegistryAddr(addr string) Option {
return func(c *conf) {
c.registryAddr = addr
}
}
// WithQsize sets the transport layer message queue size.
func WithQsize(size int) Option {
return func(c *conf) {
c.qsize = size
}
}