github.com/xmidt-org/webpa-common@v1.11.9/service/servicecfg/options.go (about) 1 package servicecfg 2 3 import ( 4 "github.com/xmidt-org/webpa-common/service" 5 "github.com/xmidt-org/webpa-common/service/consul" 6 "github.com/xmidt-org/webpa-common/service/zk" 7 ) 8 9 // Options contains the superset of all necessary options for initializing service discovery. 10 type Options struct { 11 VnodeCount int `json:"vnodeCount,omitempty"` 12 DisableFilter bool `json:"disableFilter"` 13 DefaultScheme string `json:"defaultScheme"` 14 15 Fixed []string `json:"fixed,omitempty"` 16 Zookeeper *zk.Options `json:"zookeeper,omitempty"` 17 Consul *consul.Options `json:"consul,omitempty"` 18 } 19 20 func (o *Options) vnodeCount() int { 21 if o != nil && o.VnodeCount > 0 { 22 return o.VnodeCount 23 } 24 25 return service.DefaultVnodeCount 26 } 27 28 func (o *Options) disableFilter() bool { 29 if o != nil { 30 return o.DisableFilter 31 } 32 33 return false 34 } 35 36 func (o *Options) defaultScheme() string { 37 if o != nil && len(o.DefaultScheme) > 0 { 38 return o.DefaultScheme 39 } 40 41 return service.DefaultScheme 42 }