Add Config to service options (#1336)

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
ben-toogood
2020-03-12 18:13:03 +00:00
committed by GitHub
parent 1b4e881d74
commit 47f1203e97
6 changed files with 60 additions and 24 deletions

View File

@@ -13,7 +13,6 @@ var (
DefaultName = "go.micro.config"
DefaultNamespace = "global"
DefaultPath = ""
DefaultClient = client.DefaultClient
)
type service struct {
@@ -25,7 +24,8 @@ type service struct {
}
func (m *service) Read() (set *source.ChangeSet, err error) {
req, err := m.client.Read(context.Background(), &proto.ReadRequest{
client := proto.NewConfigService(m.serviceName, client.DefaultClient)
req, err := client.Read(context.Background(), &proto.ReadRequest{
Namespace: m.namespace,
Path: m.path,
})
@@ -37,7 +37,8 @@ func (m *service) Read() (set *source.ChangeSet, err error) {
}
func (m *service) Watch() (w source.Watcher, err error) {
stream, err := m.client.Watch(context.Background(), &proto.WatchRequest{
client := proto.NewConfigService(m.serviceName, client.DefaultClient)
stream, err := client.Watch(context.Background(), &proto.WatchRequest{
Namespace: m.namespace,
Path: m.path,
})
@@ -91,7 +92,6 @@ func NewSource(opts ...source.Option) source.Source {
opts: options,
namespace: namespace,
path: path,
client: proto.NewConfigService(addr, DefaultClient),
}
return s