Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
huyangv committed Mar 5, 2024
1 parent 56589f9 commit 36bbb22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions registry/consul_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions registry/etcdv3/etcdv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/tls"
"encoding/json"
"errors"
consul "github.com/hashicorp/consul/api"
"path"
"strings"
"sync"
Expand Down Expand Up @@ -307,3 +308,7 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
configure(e, opts...)
return e
}

func (e *etcdv3Registry) GetConsulClient() *consul.Client {
return nil
}
10 changes: 8 additions & 2 deletions registry/mock/mock.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -111,3 +113,7 @@ func NewRegistry(opts ...registry.Options) registry.Registry {
m.init()
return m
}

func (m *mockRegistry) GetConsulClient() *consul.Client {
return nil
}
2 changes: 2 additions & 0 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry

import (
"errors"
consul "github.com/hashicorp/consul/api"
)

// Registry The registry provides an interface for service discovery
Expand All @@ -17,6 +18,7 @@ type Registry interface {
ListServices() ([]*Service, error)
Watch(...WatchOption) (Watcher, error)
String() string
GetConsulClient() *consul.Client
}

// Option Option
Expand Down

0 comments on commit 36bbb22

Please sign in to comment.