mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
set namespace rather than key (#1331)
This commit is contained in:
parent
7b385bf163
commit
f55493993c
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type serviceNameKey struct{}
|
||||
type keyKey struct{}
|
||||
type namespaceKey struct{}
|
||||
type pathKey struct{}
|
||||
|
||||
func ServiceName(name string) source.Option {
|
||||
@ -19,12 +19,12 @@ func ServiceName(name string) source.Option {
|
||||
}
|
||||
}
|
||||
|
||||
func Key(key string) source.Option {
|
||||
func Namespace(namespace string) source.Option {
|
||||
return func(o *source.Options) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, keyKey{}, key)
|
||||
o.Context = context.WithValue(o.Context, namespaceKey{}, namespace)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: go-micro/config/source/service/proto/service.proto
|
||||
// source: github.com/micro/go-micro/config/source/service/proto/service.proto
|
||||
|
||||
package service
|
||||
|
||||
@ -35,7 +35,7 @@ func (m *ChangeSet) Reset() { *m = ChangeSet{} }
|
||||
func (m *ChangeSet) String() string { return proto.CompactTextString(m) }
|
||||
func (*ChangeSet) ProtoMessage() {}
|
||||
func (*ChangeSet) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{0}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{0}
|
||||
}
|
||||
|
||||
func (m *ChangeSet) XXX_Unmarshal(b []byte) error {
|
||||
@ -92,7 +92,7 @@ func (m *ChangeSet) GetTimestamp() int64 {
|
||||
}
|
||||
|
||||
type Change struct {
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
|
||||
ChangeSet *ChangeSet `protobuf:"bytes,3,opt,name=changeSet,proto3" json:"changeSet,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@ -104,7 +104,7 @@ func (m *Change) Reset() { *m = Change{} }
|
||||
func (m *Change) String() string { return proto.CompactTextString(m) }
|
||||
func (*Change) ProtoMessage() {}
|
||||
func (*Change) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{1}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{1}
|
||||
}
|
||||
|
||||
func (m *Change) XXX_Unmarshal(b []byte) error {
|
||||
@ -125,9 +125,9 @@ func (m *Change) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Change proto.InternalMessageInfo
|
||||
|
||||
func (m *Change) GetKey() string {
|
||||
func (m *Change) GetNamespace() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
return m.Namespace
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -157,7 +157,7 @@ func (m *CreateRequest) Reset() { *m = CreateRequest{} }
|
||||
func (m *CreateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CreateRequest) ProtoMessage() {}
|
||||
func (*CreateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{2}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{2}
|
||||
}
|
||||
|
||||
func (m *CreateRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -195,7 +195,7 @@ func (m *CreateResponse) Reset() { *m = CreateResponse{} }
|
||||
func (m *CreateResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CreateResponse) ProtoMessage() {}
|
||||
func (*CreateResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{3}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{3}
|
||||
}
|
||||
|
||||
func (m *CreateResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -227,7 +227,7 @@ func (m *UpdateRequest) Reset() { *m = UpdateRequest{} }
|
||||
func (m *UpdateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*UpdateRequest) ProtoMessage() {}
|
||||
func (*UpdateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{4}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{4}
|
||||
}
|
||||
|
||||
func (m *UpdateRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -265,7 +265,7 @@ func (m *UpdateResponse) Reset() { *m = UpdateResponse{} }
|
||||
func (m *UpdateResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*UpdateResponse) ProtoMessage() {}
|
||||
func (*UpdateResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{5}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{5}
|
||||
}
|
||||
|
||||
func (m *UpdateResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -297,7 +297,7 @@ func (m *DeleteRequest) Reset() { *m = DeleteRequest{} }
|
||||
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteRequest) ProtoMessage() {}
|
||||
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{6}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{6}
|
||||
}
|
||||
|
||||
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -335,7 +335,7 @@ func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteResponse) ProtoMessage() {}
|
||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{7}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{7}
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -366,7 +366,7 @@ func (m *ListRequest) Reset() { *m = ListRequest{} }
|
||||
func (m *ListRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListRequest) ProtoMessage() {}
|
||||
func (*ListRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{8}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{8}
|
||||
}
|
||||
|
||||
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -398,7 +398,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} }
|
||||
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListResponse) ProtoMessage() {}
|
||||
func (*ListResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{9}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{9}
|
||||
}
|
||||
|
||||
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -427,7 +427,7 @@ func (m *ListResponse) GetValues() []*Change {
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@ -438,7 +438,7 @@ func (m *ReadRequest) Reset() { *m = ReadRequest{} }
|
||||
func (m *ReadRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ReadRequest) ProtoMessage() {}
|
||||
func (*ReadRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{10}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{10}
|
||||
}
|
||||
|
||||
func (m *ReadRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -459,9 +459,9 @@ func (m *ReadRequest) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_ReadRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *ReadRequest) GetKey() string {
|
||||
func (m *ReadRequest) GetNamespace() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
return m.Namespace
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -484,7 +484,7 @@ func (m *ReadResponse) Reset() { *m = ReadResponse{} }
|
||||
func (m *ReadResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ReadResponse) ProtoMessage() {}
|
||||
func (*ReadResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{11}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{11}
|
||||
}
|
||||
|
||||
func (m *ReadResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -513,7 +513,7 @@ func (m *ReadResponse) GetChange() *Change {
|
||||
}
|
||||
|
||||
type WatchRequest struct {
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@ -524,7 +524,7 @@ func (m *WatchRequest) Reset() { *m = WatchRequest{} }
|
||||
func (m *WatchRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*WatchRequest) ProtoMessage() {}
|
||||
func (*WatchRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{12}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{12}
|
||||
}
|
||||
|
||||
func (m *WatchRequest) XXX_Unmarshal(b []byte) error {
|
||||
@ -545,9 +545,9 @@ func (m *WatchRequest) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_WatchRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *WatchRequest) GetKey() string {
|
||||
func (m *WatchRequest) GetNamespace() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
return m.Namespace
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -560,7 +560,7 @@ func (m *WatchRequest) GetPath() string {
|
||||
}
|
||||
|
||||
type WatchResponse struct {
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||
ChangeSet *ChangeSet `protobuf:"bytes,2,opt,name=changeSet,proto3" json:"changeSet,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@ -571,7 +571,7 @@ func (m *WatchResponse) Reset() { *m = WatchResponse{} }
|
||||
func (m *WatchResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*WatchResponse) ProtoMessage() {}
|
||||
func (*WatchResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_05971a9aaecb0484, []int{13}
|
||||
return fileDescriptor_54fcef0de4ea31b3, []int{13}
|
||||
}
|
||||
|
||||
func (m *WatchResponse) XXX_Unmarshal(b []byte) error {
|
||||
@ -592,9 +592,9 @@ func (m *WatchResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_WatchResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *WatchResponse) GetKey() string {
|
||||
func (m *WatchResponse) GetNamespace() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
return m.Namespace
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -624,37 +624,38 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("go-micro/config/source/service/proto/service.proto", fileDescriptor_05971a9aaecb0484)
|
||||
proto.RegisterFile("github.com/micro/go-micro/config/source/service/proto/service.proto", fileDescriptor_54fcef0de4ea31b3)
|
||||
}
|
||||
|
||||
var fileDescriptor_05971a9aaecb0484 = []byte{
|
||||
// 443 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6a, 0xdb, 0x40,
|
||||
0x10, 0xc6, 0x2d, 0xdb, 0x51, 0xab, 0xb1, 0x24, 0x87, 0x39, 0x14, 0x21, 0x0a, 0x35, 0x82, 0x82,
|
||||
0x69, 0xe9, 0x2a, 0x38, 0x7d, 0x03, 0xf7, 0xd6, 0x9e, 0x54, 0x4a, 0x7b, 0xdd, 0xca, 0x13, 0x5b,
|
||||
0x24, 0xf2, 0xaa, 0xda, 0x75, 0xa0, 0x8f, 0x90, 0xb7, 0x2e, 0xfb, 0x47, 0xb1, 0xe4, 0x82, 0x89,
|
||||
0x6f, 0x3b, 0x33, 0x3b, 0xdf, 0x7c, 0x9a, 0x9f, 0x16, 0x56, 0x5b, 0xf1, 0xa9, 0xae, 0xca, 0x56,
|
||||
0xe4, 0xa5, 0xd8, 0xdf, 0x55, 0xdb, 0x5c, 0x8a, 0x43, 0x5b, 0x52, 0x2e, 0xa9, 0x7d, 0xac, 0x4a,
|
||||
0xca, 0x9b, 0x56, 0x28, 0xd1, 0x45, 0xcc, 0x44, 0xd9, 0x93, 0x07, 0xc1, 0x7a, 0xc7, 0xf7, 0x5b,
|
||||
0xfa, 0x4e, 0x0a, 0x11, 0xa6, 0x1b, 0xae, 0x78, 0xe2, 0x2d, 0xbc, 0x65, 0x58, 0x98, 0x33, 0xa6,
|
||||
0xf0, 0xba, 0xdc, 0x51, 0x79, 0x2f, 0x0f, 0x75, 0x32, 0x5e, 0x78, 0xcb, 0xa0, 0x78, 0x8e, 0xf1,
|
||||
0x0d, 0xf8, 0x77, 0xa2, 0xad, 0xb9, 0x4a, 0x26, 0xa6, 0xe2, 0x22, 0x9d, 0xb7, 0xb3, 0x93, 0x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 0x0c, 0xf4, 0xd5,
|
||||
0xd3, 0x18, 0xfc, 0xb5, 0x79, 0x08, 0xf8, 0x11, 0x7c, 0x4b, 0x13, 0x63, 0x36, 0xf8, 0x11, 0xd2,
|
||||
0x39, 0x3b, 0xc1, 0x3c, 0xd2, 0x97, 0x2d, 0x36, 0x8c, 0xd9, 0x80, 0x78, 0x3a, 0x67, 0x27, 0x3c,
|
||||
0xcd, 0x65, 0xcb, 0x07, 0x63, 0x36, 0x40, 0x9b, 0xce, 0xd9, 0x09, 0xb8, 0x11, 0xbe, 0x87, 0xa9,
|
||||
0x66, 0x85, 0x21, 0xeb, 0x11, 0x4c, 0x23, 0xd6, 0x07, 0x68, 0xaf, 0xe9, 0x65, 0x63, 0xc8, 0x7a,
|
||||
0xa0, 0xd2, 0x88, 0xf5, 0x09, 0x64, 0x23, 0xfc, 0x00, 0x57, 0x66, 0x59, 0x18, 0xb1, 0xfe, 0xaa,
|
||||
0xd3, 0x98, 0x0d, 0x76, 0x98, 0x8d, 0x6e, 0xbc, 0xdf, 0xbe, 0x79, 0xed, 0xb7, 0xff, 0x02, 0x00,
|
||||
0x00, 0xff, 0xff, 0xea, 0xa0, 0x1e, 0x8e, 0x23, 0x04, 0x00, 0x00,
|
||||
var fileDescriptor_54fcef0de4ea31b3 = []byte{
|
||||
// 455 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcd, 0x8e, 0x9b, 0x30,
|
||||
0x10, 0xc7, 0x43, 0x92, 0xa5, 0x65, 0x02, 0xa4, 0xf2, 0xa1, 0x42, 0xa8, 0x52, 0x23, 0xa4, 0x4a,
|
||||
0x51, 0xab, 0x9a, 0x55, 0xfa, 0x00, 0xad, 0x94, 0x1e, 0x7b, 0xa2, 0xaa, 0xf6, 0xec, 0x75, 0x66,
|
||||
0x03, 0xea, 0x12, 0x53, 0x6c, 0xf6, 0x1d, 0xf6, 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, 0x90, 0x6d, 0x9a, 0x86, 0x40, 0x42, 0x3a, 0x82, 0x99, 0x46, 0x74, 0x4c,
|
||||
0x26, 0x9b, 0x91, 0xcf, 0x70, 0x63, 0x1e, 0x8e, 0x44, 0x74, 0x8c, 0x20, 0x8d, 0xe9, 0xe4, 0x3d,
|
||||
0xb3, 0xd9, 0xad, 0x77, 0xef, 0x9b, 0xbf, 0xc3, 0xb7, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcb,
|
||||
0x26, 0xcb, 0xd9, 0x64, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: go-micro/config/source/service/proto/service.proto
|
||||
// source: github.com/micro/go-micro/config/source/service/proto/service.proto
|
||||
|
||||
package service
|
||||
|
||||
@ -48,12 +48,6 @@ type configService struct {
|
||||
}
|
||||
|
||||
func NewConfigService(name string, c client.Client) ConfigService {
|
||||
if c == nil {
|
||||
c = client.NewClient()
|
||||
}
|
||||
if len(name) == 0 {
|
||||
name = "config"
|
||||
}
|
||||
return &configService{
|
||||
c: c,
|
||||
name: name,
|
||||
@ -123,6 +117,7 @@ func (c *configService) Watch(ctx context.Context, in *WatchRequest, opts ...cli
|
||||
}
|
||||
|
||||
type Config_WatchService interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
@ -137,6 +132,10 @@ func (x *configServiceWatch) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *configServiceWatch) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *configServiceWatch) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
@ -214,6 +213,7 @@ func (h *configHandler) Watch(ctx context.Context, stream server.Stream) error {
|
||||
}
|
||||
|
||||
type Config_WatchStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
@ -228,6 +228,10 @@ func (x *configWatchStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *configWatchStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *configWatchStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ message ChangeSet {
|
||||
}
|
||||
|
||||
message Change {
|
||||
string key = 1;
|
||||
string namespace = 1;
|
||||
string path = 2;
|
||||
ChangeSet changeSet = 3;
|
||||
}
|
||||
@ -48,7 +48,7 @@ message ListResponse {
|
||||
}
|
||||
|
||||
message ReadRequest {
|
||||
string key = 1;
|
||||
string namespace = 1;
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
@ -57,11 +57,11 @@ message ReadResponse {
|
||||
}
|
||||
|
||||
message WatchRequest {
|
||||
string key = 1;
|
||||
string namespace = 1;
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
message WatchResponse {
|
||||
string key = 1;
|
||||
string namespace = 1;
|
||||
ChangeSet changeSet = 2;
|
||||
}
|
||||
|
@ -10,22 +10,25 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultName = "go.micro.config"
|
||||
DefaultKey = "NAMESPACE:CONFIG"
|
||||
DefaultPath = ""
|
||||
DefaultClient = client.DefaultClient
|
||||
DefaultName = "go.micro.config"
|
||||
DefaultNamespace = "global"
|
||||
DefaultPath = ""
|
||||
DefaultClient = client.DefaultClient
|
||||
)
|
||||
|
||||
type service struct {
|
||||
serviceName string
|
||||
key string
|
||||
namespace string
|
||||
path string
|
||||
opts source.Options
|
||||
client proto.ConfigService
|
||||
}
|
||||
|
||||
func (m *service) Read() (set *source.ChangeSet, err error) {
|
||||
req, err := m.client.Read(context.Background(), &proto.ReadRequest{Key: m.key, Path: m.path})
|
||||
req, err := m.client.Read(context.Background(), &proto.ReadRequest{
|
||||
Namespace: m.namespace,
|
||||
Path: m.path,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -34,7 +37,10 @@ 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{Key: m.key, Path: m.path})
|
||||
stream, err := m.client.Watch(context.Background(), &proto.WatchRequest{
|
||||
Namespace: m.namespace,
|
||||
Path: m.path,
|
||||
})
|
||||
if err != nil {
|
||||
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
|
||||
logger.Error("watch err: ", err)
|
||||
@ -60,7 +66,7 @@ func NewSource(opts ...source.Option) source.Source {
|
||||
}
|
||||
|
||||
addr := DefaultName
|
||||
key := DefaultKey
|
||||
namespace := DefaultNamespace
|
||||
path := DefaultPath
|
||||
|
||||
if options.Context != nil {
|
||||
@ -69,9 +75,9 @@ func NewSource(opts ...source.Option) source.Source {
|
||||
addr = a
|
||||
}
|
||||
|
||||
k, ok := options.Context.Value(keyKey{}).(string)
|
||||
k, ok := options.Context.Value(namespaceKey{}).(string)
|
||||
if ok {
|
||||
key = k
|
||||
namespace = k
|
||||
}
|
||||
|
||||
p, ok := options.Context.Value(pathKey{}).(string)
|
||||
@ -83,7 +89,7 @@ func NewSource(opts ...source.Option) source.Source {
|
||||
s := &service{
|
||||
serviceName: addr,
|
||||
opts: options,
|
||||
key: key,
|
||||
namespace: namespace,
|
||||
path: path,
|
||||
client: proto.NewConfigService(addr, DefaultClient),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user