fix: client discovery func return (#632)

This commit is contained in:
ningyiming
2021-08-30 15:14:41 +08:00
parent a0e6122391
commit 995e0c5e79
7 changed files with 13 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ type ConsulDiscovery struct {
}
// NewConsulDiscovery returns a new ConsulDiscovery.
func NewConsulDiscovery(basePath, servicePath string, consulAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewConsulDiscovery(basePath, servicePath string, consulAddr []string, options *store.Config) (*ConsulDiscovery, error) {
kv, err := libkv.NewStore(store.CONSUL, consulAddr, options)
if err != nil {
log.Infof("cannot create store: %v", err)
@@ -44,7 +44,7 @@ func NewConsulDiscovery(basePath, servicePath string, consulAddr []string, optio
}
// NewConsulDiscoveryStore returns a new ConsulDiscovery with specified store.
func NewConsulDiscoveryStore(basePath string, kv store.Store) (ServiceDiscovery, error) {
func NewConsulDiscoveryStore(basePath string, kv store.Store) (*ConsulDiscovery, error) {
if basePath[0] == '/' {
basePath = basePath[1:]
}
@@ -84,7 +84,7 @@ func NewConsulDiscoveryStore(basePath string, kv store.Store) (ServiceDiscovery,
}
// NewConsulDiscoveryTemplate returns a new ConsulDiscovery template.
func NewConsulDiscoveryTemplate(basePath string, consulAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewConsulDiscoveryTemplate(basePath string, consulAddr []string, options *store.Config) (*ConsulDiscovery, error) {
if basePath[0] == '/' {
basePath = basePath[1:]
}

View File

@@ -30,7 +30,7 @@ type DNSDiscovery struct {
}
// NewPeer2PeerDiscovery returns a new Peer2PeerDiscovery.
func NewDNSDiscovery(domain string, network string, port int, d time.Duration) (ServiceDiscovery, error) {
func NewDNSDiscovery(domain string, network string, port int, d time.Duration) (*DNSDiscovery, error) {
discovery := &DNSDiscovery{domain: domain, network: network, port: port, d: d}
discovery.lookup()
go discovery.watch()

View File

@@ -37,7 +37,7 @@ type MDNSDiscovery struct {
// NewMDNSDiscovery returns a new MDNSDiscovery.
// If domain is empty, use "local." in default.
func NewMDNSDiscovery(service string, timeout time.Duration, watchInterval time.Duration, domain string) (ServiceDiscovery, error) {
func NewMDNSDiscovery(service string, timeout time.Duration, watchInterval time.Duration, domain string) (*MDNSDiscovery, error) {
if domain == "" {
domain = "local."
}

View File

@@ -18,7 +18,7 @@ type MultipleServersDiscovery struct {
}
// NewMultipleServersDiscovery returns a new MultipleServersDiscovery.
func NewMultipleServersDiscovery(pairs []*KVPair) (ServiceDiscovery, error) {
func NewMultipleServersDiscovery(pairs []*KVPair) (*MultipleServersDiscovery, error) {
return &MultipleServersDiscovery{
pairs: pairs,
}, nil

View File

@@ -8,7 +8,7 @@ type Peer2PeerDiscovery struct {
}
// NewPeer2PeerDiscovery returns a new Peer2PeerDiscovery.
func NewPeer2PeerDiscovery(server, metadata string) (ServiceDiscovery, error) {
func NewPeer2PeerDiscovery(server, metadata string) (*Peer2PeerDiscovery, error) {
return &Peer2PeerDiscovery{server: server, metadata: metadata}, nil
}

View File

@@ -34,7 +34,7 @@ type RedisDiscovery struct {
}
// NewRedisDiscovery returns a new RedisDiscovery.
func NewRedisDiscovery(basePath string, servicePath string, redisAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewRedisDiscovery(basePath string, servicePath string, redisAddr []string, options *store.Config) (*RedisDiscovery, error) {
kv, err := libkv.NewStore(store.REDIS, redisAddr, options)
if err != nil {
log.Infof("cannot create store: %v", err)
@@ -45,7 +45,7 @@ func NewRedisDiscovery(basePath string, servicePath string, redisAddr []string,
}
// NewRedisDiscoveryStore return a new RedisDiscovery with specified store.
func NewRedisDiscoveryStore(basePath string, kv store.Store) (ServiceDiscovery, error) {
func NewRedisDiscoveryStore(basePath string, kv store.Store) (*RedisDiscovery, error) {
if len(basePath) > 1 && strings.HasSuffix(basePath, "/") {
basePath = basePath[:len(basePath)-1]
}
@@ -96,7 +96,7 @@ func NewRedisDiscoveryStore(basePath string, kv store.Store) (ServiceDiscovery,
}
// NewRedisDiscoveryTemplate returns a new RedisDiscovery template.
func NewRedisDiscoveryTemplate(basePath string, etcdAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewRedisDiscoveryTemplate(basePath string, etcdAddr []string, options *store.Config) (*RedisDiscovery, error) {
if len(basePath) > 1 && strings.HasSuffix(basePath, "/") {
basePath = basePath[:len(basePath)-1]
}

View File

@@ -34,7 +34,7 @@ type ZookeeperDiscovery struct {
}
// NewZookeeperDiscovery returns a new ZookeeperDiscovery.
func NewZookeeperDiscovery(basePath string, servicePath string, zkAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewZookeeperDiscovery(basePath string, servicePath string, zkAddr []string, options *store.Config) (*ZookeeperDiscovery, error) {
if basePath[0] == '/' {
basePath = basePath[1:]
}
@@ -53,7 +53,7 @@ func NewZookeeperDiscovery(basePath string, servicePath string, zkAddr []string,
}
// NewZookeeperDiscoveryWithStore returns a new ZookeeperDiscovery with specified store.
func NewZookeeperDiscoveryWithStore(basePath string, kv store.Store) (ServiceDiscovery, error) {
func NewZookeeperDiscoveryWithStore(basePath string, kv store.Store) (*ZookeeperDiscovery, error) {
if basePath[0] == '/' {
basePath = basePath[1:]
}
@@ -84,7 +84,7 @@ func NewZookeeperDiscoveryWithStore(basePath string, kv store.Store) (ServiceDis
}
// NewZookeeperDiscoveryTemplate returns a new ZookeeperDiscovery template.
func NewZookeeperDiscoveryTemplate(basePath string, zkAddr []string, options *store.Config) (ServiceDiscovery, error) {
func NewZookeeperDiscoveryTemplate(basePath string, zkAddr []string, options *store.Config) (*ZookeeperDiscovery, error) {
if basePath[0] == '/' {
basePath = basePath[1:]
}