registry/service: pass domain options via rpc (#1719)

* registry/service: regenerate proto

* registry/service: pass domain in proto request options

* registry/service: stop defaulting metadata

* registry: add default domain const; remove from implementations

* registry/memory: fix typo
This commit is contained in:
ben-toogood 2020-06-19 10:34:12 +01:00 committed by GitHub
parent c16f4b741c
commit 58c6bbbf6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1073 additions and 1258 deletions

View File

@ -20,9 +20,7 @@ import (
"github.com/micro/go-micro/v2/util/mdns"
)
var (
// use a .micro tld rather than .local by default
defaultDomain = "micro"
const (
// every service is written to the global domain so * domain queries work, e.g.
// calling mdns.List(registry.ListDomain("*")) will list the services across all
// domains
@ -149,7 +147,7 @@ func newRegistry(opts ...Option) Registry {
}
// set the domain
defaultDomain := defaultDomain
defaultDomain := DefaultDomain
d, ok := options.Context.Value("mdns.domain").(string)
if ok {

View File

@ -14,7 +14,6 @@ import (
var (
sendEventTime = 10 * time.Millisecond
ttlPruneTime = time.Second
defaultDomain = "micro"
)
type node struct {
@ -60,7 +59,7 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
reg := &Registry{
options: options,
records: map[string]services{defaultDomain: records},
records: map[string]services{registry.DefaultDomain: records},
watchers: make(map[string]*Watcher),
}
@ -129,7 +128,7 @@ func (m *Registry) Init(opts ...registry.Option) error {
defer m.Unlock()
// get the existing services from the records
srvs, ok := m.records[defaultDomain]
srvs, ok := m.records[registry.DefaultDomain]
if !ok {
srvs = make(services)
}
@ -151,7 +150,7 @@ func (m *Registry) Init(opts ...registry.Option) error {
}
// set the services in the registry
m.records[defaultDomain] = srvs
m.records[registry.DefaultDomain] = srvs
return nil
}
@ -169,7 +168,7 @@ func (m *Registry) Register(s *registry.Service, opts ...registry.RegisterOption
o(&options)
}
if len(options.Domain) == 0 {
options.Domain = defaultDomain
options.Domain = registry.DefaultDomain
}
// get the services for this domain from the registry
@ -243,7 +242,7 @@ func (m *Registry) Deregister(s *registry.Service, opts ...registry.DeregisterOp
o(&options)
}
if len(options.Domain) == 0 {
options.Domain = defaultDomain
options.Domain = registry.DefaultDomain
}
// if the domain doesn't exist, there is nothing to deregister
@ -307,7 +306,7 @@ func (m *Registry) GetService(name string, opts ...registry.GetOption) ([]*regis
o(&options)
}
if len(options.Domain) == 0 {
options.Domain = defaultDomain
options.Domain = registry.DefaultDomain
}
// if it's a wildcard domain, return from all domains
@ -365,7 +364,7 @@ func (m *Registry) ListServices(opts ...registry.ListOption) ([]*registry.Servic
o(&options)
}
if len(options.Domain) == 0 {
options.Domain = defaultDomain
options.Domain = registry.DefaultDomain
}
// if it's a wildcard domain, list from all domains
@ -412,7 +411,7 @@ func (m *Registry) Watch(opts ...registry.WatchOption) (registry.Watcher, error)
o(&wo)
}
if len(wo.Domain) == 0 {
wo.Domain = defaultDomain
wo.Domain = registry.DefaultDomain
}
// construct the watcher

View File

@ -8,6 +8,8 @@ import (
const (
// WildcardDomain indicates any domain
WildcardDomain = "*"
// DefaultDomain to use if none was provided in options
DefaultDomain = "micro"
)
var (

View File

@ -320,6 +320,7 @@ func (m *Value) GetValues() []*Value {
// Options are registry options
type Options struct {
Ttl int64 `protobuf:"varint,1,opt,name=ttl,proto3" json:"ttl,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -357,6 +358,13 @@ func (m *Options) GetTtl() int64 {
return 0
}
func (m *Options) GetDomain() string {
if m != nil {
return m.Domain
}
return ""
}
// Result is returns by the watcher
type Result struct {
Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"`
@ -446,6 +454,7 @@ var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo
type GetRequest struct {
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
Options *Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -483,6 +492,13 @@ func (m *GetRequest) GetService() string {
return ""
}
func (m *GetRequest) GetOptions() *Options {
if m != nil {
return m.Options
}
return nil
}
type GetResponse struct {
Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -523,6 +539,7 @@ func (m *GetResponse) GetServices() []*Service {
}
type ListRequest struct {
Options *Options `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -553,6 +570,13 @@ func (m *ListRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_ListRequest proto.InternalMessageInfo
func (m *ListRequest) GetOptions() *Options {
if m != nil {
return m.Options
}
return nil
}
type ListResponse struct {
Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -595,6 +619,7 @@ func (m *ListResponse) GetServices() []*Service {
type WatchRequest struct {
// service is optional
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
Options *Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -632,6 +657,13 @@ func (m *WatchRequest) GetService() string {
return ""
}
func (m *WatchRequest) GetOptions() *Options {
if m != nil {
return m.Options
}
return nil
}
// Event is registry event
type Event struct {
// Event Id
@ -725,50 +757,51 @@ func init() {
}
var fileDescriptor_3f5817c11f323eb6 = []byte{
// 675 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6e, 0xd3, 0x4c,
0x10, 0x8d, 0x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xd5, 0xba, 0x3b, 0xf8, 0xe6,
0x41, 0x93, 0x99, 0x72, 0x78, 0xa2, 0xa7, 0x69, 0xff, 0x04, 0x37, 0x4a, 0x0e, 0x5c, 0x0c, 0x3b,
0xb8, 0xb9, 0x6a, 0xdb, 0x58, 0xa3, 0x82, 0x2f, 0x6c, 0x69, 0xe2, 0xb8, 0xa6, 0xfb, 0xa0, 0x53,
0x26, 0xd6, 0x39, 0x9b, 0x55, 0xf0, 0x18, 0xe0, 0x90, 0xf8, 0xdf, 0xaa, 0xf6, 0xba, 0x30, 0x8e,
0xa1, 0x08, 0x2c, 0xbb, 0xcb, 0x92, 0xd1, 0x82, 0x5b, 0x2b, 0xf7, 0xe7, 0x25, 0x8f, 0xa0, 0xa6,
0x3d, 0x84, 0x65, 0xd8, 0x65, 0x77, 0x05, 0xd7, 0x4b, 0x00, 0xc5, 0x5b, 0x0e, 0x2b, 0xfb, 0xce,
0xc7, 0xba, 0xfe, 0x4d, 0xdf, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xc6, 0xa5, 0x5a, 0xc9, 0xcf,
0x07, 0x00, 0x00,
// 700 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xed, 0x6a, 0xd4, 0x40,
0x14, 0xdd, 0x24, 0xfb, 0x79, 0xb7, 0xad, 0x75, 0x10, 0x8d, 0xb1, 0xea, 0x12, 0x28, 0xac, 0x82,
0xbb, 0x65, 0x5b, 0xc4, 0x8f, 0x5f, 0xd2, 0xae, 0x05, 0x69, 0x15, 0xc7, 0xaf, 0x3f, 0x22, 0xc4,
0xcd, 0xa5, 0x06, 0x37, 0x99, 0x38, 0x33, 0x5d, 0xd8, 0x77, 0x10, 0x7c, 0x02, 0xdf, 0xc6, 0xa7,
0xf0, 0x69, 0x64, 0x26, 0x93, 0x6c, 0x4a, 0xb3, 0x4b, 0xa1, 0xf6, 0xdf, 0x9d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0xa8, 0x91, 0x23, 0x80,
0x03, 0xe4, 0xff, 0x4b, 0xed, 0x6d, 0x16, 0x37, 0x43, 0x11, 0xa4, 0xea, 0x2c, 0xa5, 0x50, 0x7b,
0xf7, 0x97, 0xbe, 0x2f, 0x24, 0x0f, 0xa1, 0xa1, 0x93, 0x47, 0xaa, 0xb0, 0xe5, 0x4c, 0x7a, 0xb7,
0x2b, 0x00, 0xd9, 0xd7, 0xc6, 0xaf, 0xed, 0x58, 0x5f, 0x9b, 0xfa, 0x0f, 0xc6, 0xee, 0xbf, 0x00,
0x00, 0x00, 0xff, 0xff, 0xef, 0xac, 0x43, 0xb5, 0x89, 0x08, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -12,12 +12,12 @@ service Registry {
// Service represents a go-micro service
message Service {
string name = 1;
string version = 2;
map<string,string> metadata = 3;
repeated Endpoint endpoints = 4;
repeated Node nodes = 5;
Options options = 6;
string name = 1;
string version = 2;
map<string,string> metadata = 3;
repeated Endpoint endpoints = 4;
repeated Node nodes = 5;
Options options = 6;
}
// Node represents the node the service is on
@ -45,7 +45,8 @@ message Value {
// Options are registry options
message Options {
int64 ttl = 1;
int64 ttl = 1;
string domain = 2;
}
// Result is returns by the watcher
@ -59,6 +60,7 @@ message EmptyResponse {}
message GetRequest {
string service = 1;
Options options = 2;
}
message GetResponse {
@ -66,7 +68,7 @@ message GetResponse {
}
message ListRequest {
// TODO: filtering
Options options = 1;
}
message ListResponse {
@ -76,23 +78,24 @@ message ListResponse {
message WatchRequest {
// service is optional
string service = 1;
Options options = 2;
}
// EventType defines the type of event
enum EventType {
Create = 0;
Delete = 1;
Update = 2;
Create = 0;
Delete = 1;
Update = 2;
}
// Event is registry event
message Event {
// Event Id
string id = 1;
// type of event
EventType type = 2;
// unix timestamp of event
int64 timestamp = 3;
// service entry
Service service = 4;
// Event Id
string id = 1;
// type of event
EventType type = 2;
// unix timestamp of event
int64 timestamp = 3;
// service entry
Service service = 4;
}

View File

@ -78,17 +78,14 @@ func (s *serviceRegistry) Register(srv *registry.Service, opts ...registry.Regis
options.Context = context.TODO()
}
// encode srv into protobuf and pack Register TTL into it
// encode srv into protobuf and pack TTL and domain into it
pbSrv := ToProto(srv)
pbSrv.Options.Ttl = int64(options.TTL.Seconds())
pbSrv.Options.Domain = options.Domain
// register the service
_, err := s.client.Register(options.Context, pbSrv, s.callOpts()...)
if err != nil {
return err
}
return nil
return err
}
func (s *serviceRegistry) Deregister(srv *registry.Service, opts ...registry.DeregisterOption) error {
@ -100,12 +97,13 @@ func (s *serviceRegistry) Deregister(srv *registry.Service, opts ...registry.Der
options.Context = context.TODO()
}
// encode srv into protobuf and pack domain into it
pbSrv := ToProto(srv)
pbSrv.Options.Domain = options.Domain
// deregister the service
_, err := s.client.Deregister(options.Context, ToProto(srv), s.callOpts()...)
if err != nil {
return err
}
return nil
_, err := s.client.Deregister(options.Context, pbSrv, s.callOpts()...)
return err
}
func (s *serviceRegistry) GetService(name string, opts ...registry.GetOption) ([]*registry.Service, error) {
@ -118,7 +116,7 @@ func (s *serviceRegistry) GetService(name string, opts ...registry.GetOption) ([
}
rsp, err := s.client.GetService(options.Context, &pb.GetRequest{
Service: name,
Service: name, Options: &pb.Options{Domain: options.Domain},
}, s.callOpts()...)
if verr, ok := err.(*errors.Error); ok && verr.Code == 404 {
@ -143,7 +141,8 @@ func (s *serviceRegistry) ListServices(opts ...registry.ListOption) ([]*registry
options.Context = context.TODO()
}
rsp, err := s.client.ListServices(options.Context, &pb.ListRequest{}, s.callOpts()...)
req := &pb.ListRequest{Options: &pb.Options{Domain: options.Domain}}
rsp, err := s.client.ListServices(options.Context, req, s.callOpts()...)
if err != nil {
return nil, err
}
@ -166,7 +165,7 @@ func (s *serviceRegistry) Watch(opts ...registry.WatchOption) (registry.Watcher,
}
stream, err := s.client.Watch(options.Context, &pb.WatchRequest{
Service: options.Service,
Service: options.Service, Options: &pb.Options{Domain: options.Domain},
}, s.callOpts()...)
if err != nil {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: github.com/micro/go-micro/store/service/proto/store.proto
// source: store/service/proto/store.proto
package go_micro_store