From 36bbb228073f03f6323a2a102e96c37ce51c5c59 Mon Sep 17 00:00:00 2001 From: husong <408509165@qq.com> Date: Tue, 5 Mar 2024 13:33:47 +0800 Subject: [PATCH] 1 --- registry/consul_registry.go | 4 ++++ registry/etcdv3/etcdv3.go | 5 +++++ registry/mock/mock.go | 10 ++++++++-- registry/registry.go | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/registry/consul_registry.go b/registry/consul_registry.go index 3aa1dc3..85e4bbf 100644 --- a/registry/consul_registry.go +++ b/registry/consul_registry.go @@ -350,3 +350,7 @@ func (c *consulRegistry) String() string { func (c *consulRegistry) Options() Options { return c.opts } + +func (c *consulRegistry) GetConsulClient() *consul.Client { + return c.Client +} diff --git a/registry/etcdv3/etcdv3.go b/registry/etcdv3/etcdv3.go index 0824b41..2b936f0 100644 --- a/registry/etcdv3/etcdv3.go +++ b/registry/etcdv3/etcdv3.go @@ -6,6 +6,7 @@ import ( "crypto/tls" "encoding/json" "errors" + consul "github.com/hashicorp/consul/api" "path" "strings" "sync" @@ -307,3 +308,7 @@ func NewRegistry(opts ...registry.Option) registry.Registry { configure(e, opts...) return e } + +func (e *etcdv3Registry) GetConsulClient() *consul.Client { + return nil +} diff --git a/registry/mock/mock.go b/registry/mock/mock.go index e016c62..97e49c5 100644 --- a/registry/mock/mock.go +++ b/registry/mock/mock.go @@ -1,7 +1,9 @@ package mock -import () -import "github.com/huyangv/vmqant/registry" +import ( + consul "github.com/hashicorp/consul/api" + "github.com/huyangv/vmqant/registry" +) type mockRegistry struct { Services map[string][]*registry.Service @@ -111,3 +113,7 @@ func NewRegistry(opts ...registry.Options) registry.Registry { m.init() return m } + +func (m *mockRegistry) GetConsulClient() *consul.Client { + return nil +} diff --git a/registry/registry.go b/registry/registry.go index a540e2f..3ec18af 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -3,6 +3,7 @@ package registry import ( "errors" + consul "github.com/hashicorp/consul/api" ) // Registry The registry provides an interface for service discovery @@ -17,6 +18,7 @@ type Registry interface { ListServices() ([]*Service, error) Watch(...WatchOption) (Watcher, error) String() string + GetConsulClient() *consul.Client } // Option Option