Merge branch 'master' of ssh://github.com/micro/go-micro

This commit is contained in:
Asim Aslam 2019-07-11 21:46:33 +01:00
commit 5157241c88
3 changed files with 194 additions and 65 deletions

View File

@ -73,7 +73,7 @@ type Router_WatchService interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*TableEvent, error)
Recv() (*Event, error)
}
type routerServiceWatch struct {
@ -92,8 +92,8 @@ func (x *routerServiceWatch) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *routerServiceWatch) Recv() (*TableEvent, error) {
m := new(TableEvent)
func (x *routerServiceWatch) Recv() (*Event, error) {
m := new(Event)
err := x.stream.Recv(m)
if err != nil {
return nil, err
@ -158,7 +158,7 @@ type Router_WatchStream interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*TableEvent) error
Send(*Event) error
}
type routerWatchStream struct {
@ -177,7 +177,7 @@ func (x *routerWatchStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *routerWatchStream) Send(m *TableEvent) error {
func (x *routerWatchStream) Send(m *Event) error {
return x.stream.Send(m)
}

View File

@ -20,7 +20,33 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// EventType is TableEvent type
// AdvertType defines the type of advert
type AdvertType int32
const (
AdvertType_AdvertAnnounce AdvertType = 0
AdvertType_AdvertUpdate AdvertType = 1
)
var AdvertType_name = map[int32]string{
0: "AdvertAnnounce",
1: "AdvertUpdate",
}
var AdvertType_value = map[string]int32{
"AdvertAnnounce": 0,
"AdvertUpdate": 1,
}
func (x AdvertType) String() string {
return proto.EnumName(AdvertType_name, int32(x))
}
func (AdvertType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{0}
}
// EventType defines the type of event
type EventType int32
const (
@ -46,7 +72,7 @@ func (x EventType) String() string {
}
func (EventType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{0}
return fileDescriptor_367072455c71aedc, []int{1}
}
// LookupRequest is made to Lookup
@ -161,9 +187,86 @@ func (m *WatchRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_WatchRequest proto.InternalMessageInfo
// TableEvent is streamed by WatchRequest
type TableEvent struct {
// time of table event
// Advert is router advertsement streamed by Watch
type Advert struct {
// id of the advertising router
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// type of advertisement
Type AdvertType `protobuf:"varint,2,opt,name=type,proto3,enum=AdvertType" json:"type,omitempty"`
// unix timestamp of the advertisement
Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// TTL of the Advert
Ttl int64 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"`
// events is a list of advertised events
Events []*Event `protobuf:"bytes,5,rep,name=events,proto3" json:"events,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Advert) Reset() { *m = Advert{} }
func (m *Advert) String() string { return proto.CompactTextString(m) }
func (*Advert) ProtoMessage() {}
func (*Advert) Descriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{3}
}
func (m *Advert) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Advert.Unmarshal(m, b)
}
func (m *Advert) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Advert.Marshal(b, m, deterministic)
}
func (m *Advert) XXX_Merge(src proto.Message) {
xxx_messageInfo_Advert.Merge(m, src)
}
func (m *Advert) XXX_Size() int {
return xxx_messageInfo_Advert.Size(m)
}
func (m *Advert) XXX_DiscardUnknown() {
xxx_messageInfo_Advert.DiscardUnknown(m)
}
var xxx_messageInfo_Advert proto.InternalMessageInfo
func (m *Advert) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *Advert) GetType() AdvertType {
if m != nil {
return m.Type
}
return AdvertType_AdvertAnnounce
}
func (m *Advert) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
func (m *Advert) GetTtl() int64 {
if m != nil {
return m.Ttl
}
return 0
}
func (m *Advert) GetEvents() []*Event {
if m != nil {
return m.Events
}
return nil
}
// Event is routing table event
type Event struct {
// type of event
Type EventType `protobuf:"varint,1,opt,name=type,proto3,enum=EventType" json:"type,omitempty"`
// unix timestamp of event
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
@ -174,46 +277,46 @@ type TableEvent struct {
XXX_sizecache int32 `json:"-"`
}
func (m *TableEvent) Reset() { *m = TableEvent{} }
func (m *TableEvent) String() string { return proto.CompactTextString(m) }
func (*TableEvent) ProtoMessage() {}
func (*TableEvent) Descriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{3}
func (m *Event) Reset() { *m = Event{} }
func (m *Event) String() string { return proto.CompactTextString(m) }
func (*Event) ProtoMessage() {}
func (*Event) Descriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{4}
}
func (m *TableEvent) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TableEvent.Unmarshal(m, b)
func (m *Event) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Event.Unmarshal(m, b)
}
func (m *TableEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TableEvent.Marshal(b, m, deterministic)
func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Event.Marshal(b, m, deterministic)
}
func (m *TableEvent) XXX_Merge(src proto.Message) {
xxx_messageInfo_TableEvent.Merge(m, src)
func (m *Event) XXX_Merge(src proto.Message) {
xxx_messageInfo_Event.Merge(m, src)
}
func (m *TableEvent) XXX_Size() int {
return xxx_messageInfo_TableEvent.Size(m)
func (m *Event) XXX_Size() int {
return xxx_messageInfo_Event.Size(m)
}
func (m *TableEvent) XXX_DiscardUnknown() {
xxx_messageInfo_TableEvent.DiscardUnknown(m)
func (m *Event) XXX_DiscardUnknown() {
xxx_messageInfo_Event.DiscardUnknown(m)
}
var xxx_messageInfo_TableEvent proto.InternalMessageInfo
var xxx_messageInfo_Event proto.InternalMessageInfo
func (m *TableEvent) GetType() EventType {
func (m *Event) GetType() EventType {
if m != nil {
return m.Type
}
return EventType_Create
}
func (m *TableEvent) GetTimestamp() int64 {
func (m *Event) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
func (m *TableEvent) GetRoute() *Route {
func (m *Event) GetRoute() *Route {
if m != nil {
return m.Route
}
@ -231,7 +334,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_367072455c71aedc, []int{4}
return fileDescriptor_367072455c71aedc, []int{5}
}
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
@ -264,7 +367,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_367072455c71aedc, []int{5}
return fileDescriptor_367072455c71aedc, []int{6}
}
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
@ -305,7 +408,7 @@ func (m *Query) Reset() { *m = Query{} }
func (m *Query) String() string { return proto.CompactTextString(m) }
func (*Query) ProtoMessage() {}
func (*Query) Descriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{6}
return fileDescriptor_367072455c71aedc, []int{7}
}
func (m *Query) XXX_Unmarshal(b []byte) error {
@ -356,7 +459,7 @@ func (m *Route) Reset() { *m = Route{} }
func (m *Route) String() string { return proto.CompactTextString(m) }
func (*Route) ProtoMessage() {}
func (*Route) Descriptor() ([]byte, []int) {
return fileDescriptor_367072455c71aedc, []int{7}
return fileDescriptor_367072455c71aedc, []int{8}
}
func (m *Route) XXX_Unmarshal(b []byte) error {
@ -420,11 +523,13 @@ func (m *Route) GetMetric() int64 {
}
func init() {
proto.RegisterEnum("AdvertType", AdvertType_name, AdvertType_value)
proto.RegisterEnum("EventType", EventType_name, EventType_value)
proto.RegisterType((*LookupRequest)(nil), "LookupRequest")
proto.RegisterType((*LookupResponse)(nil), "LookupResponse")
proto.RegisterType((*WatchRequest)(nil), "WatchRequest")
proto.RegisterType((*TableEvent)(nil), "TableEvent")
proto.RegisterType((*Advert)(nil), "Advert")
proto.RegisterType((*Event)(nil), "Event")
proto.RegisterType((*ListRequest)(nil), "ListRequest")
proto.RegisterType((*ListResponse)(nil), "ListResponse")
proto.RegisterType((*Query)(nil), "Query")
@ -434,30 +539,34 @@ func init() {
func init() { proto.RegisterFile("router.proto", fileDescriptor_367072455c71aedc) }
var fileDescriptor_367072455c71aedc = []byte{
// 388 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x8e, 0xd3, 0x30,
0x10, 0x8d, 0xb7, 0x89, 0x51, 0xa6, 0x49, 0x58, 0xf9, 0x80, 0xac, 0x6a, 0xb5, 0x2a, 0x96, 0x10,
0x2b, 0x10, 0x66, 0x55, 0x3e, 0x01, 0xb8, 0xed, 0x05, 0x6b, 0x11, 0xe7, 0x6c, 0x3b, 0x62, 0xa3,
0xb6, 0x49, 0xd6, 0x76, 0xb6, 0xca, 0x07, 0xf0, 0x15, 0xfc, 0x2c, 0xf2, 0x24, 0xa1, 0xed, 0x01,
0x89, 0xdb, 0xbc, 0x37, 0xb6, 0xe7, 0x79, 0xde, 0x83, 0xcc, 0x36, 0x9d, 0x47, 0xab, 0x5b, 0xdb,
0xf8, 0x46, 0x7d, 0x80, 0xfc, 0xae, 0x69, 0xb6, 0x5d, 0x6b, 0xf0, 0xa9, 0x43, 0xe7, 0xc5, 0x15,
0x24, 0x4f, 0x1d, 0xda, 0x5e, 0xb2, 0x25, 0xbb, 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fb, 0x08, 0xe9, 0xdf, 0x75, 0x0a, 0x00, 0xfe, 0xd9, 0x62, 0xe9, 0xf1, 0x32, 0x0a, 0xf5,
0x17, 0xdc, 0xa1, 0xc7, 0x4b, 0x16, 0xea, 0xef, 0xed, 0x26, 0xf0, 0x17, 0xab, 0x5f, 0x0c, 0x38,
0x7d, 0xc7, 0x8a, 0xb7, 0x90, 0x90, 0x6b, 0x22, 0xd7, 0xa7, 0xee, 0x2d, 0xe6, 0xfa, 0x68, 0x9e,
0x8a, 0x6e, 0x99, 0x78, 0x0f, 0x7c, 0x08, 0x84, 0x28, 0xf4, 0x59, 0x90, 0x16, 0x2f, 0xf5, 0x79,
0x52, 0x54, 0x24, 0xde, 0x40, 0x1c, 0x2c, 0x10, 0x99, 0x3e, 0x31, 0x66, 0x91, 0xeb, 0x53, 0x5f,
0x54, 0xf4, 0xc0, 0x29, 0x9a, 0x9f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x67, 0x70, 0xf8, 0xfa,
0xaa, 0x02, 0x00, 0x00,
// 461 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x8f, 0xd3, 0x4c,
0x0c, 0xcd, 0xa4, 0x4d, 0x3e, 0xc5, 0x4d, 0xf3, 0x55, 0x3e, 0xa0, 0xa8, 0xaa, 0x96, 0x32, 0x12,
0x52, 0xb5, 0x88, 0xb0, 0x2a, 0xbf, 0x60, 0x05, 0xdc, 0xf6, 0xc2, 0x08, 0xc4, 0x39, 0x24, 0x16,
0x44, 0x6d, 0x93, 0xec, 0xcc, 0xa4, 0xab, 0xde, 0xb8, 0xf2, 0x1b, 0xf8, 0xb3, 0x68, 0x9c, 0x84,
0x76, 0x91, 0x56, 0xe2, 0xe6, 0xf7, 0x6c, 0xc7, 0x9e, 0xf7, 0x1c, 0x88, 0x75, 0xd3, 0x59, 0xd2,
0x59, 0xab, 0x1b,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xff, 0xff, 0x5e, 0x52, 0x2f, 0xa0, 0x60, 0x03, 0x00, 0x00,
}

View File

@ -2,7 +2,7 @@ syntax = "proto3";
// Router service is used by the proxy to lookup routes
service Router {
rpc Watch(WatchRequest) returns (stream TableEvent) {};
rpc Watch(WatchRequest) returns (stream Event) {};
rpc Lookup(LookupRequest) returns (LookupResponse) {};
rpc List(ListRequest) returns (ListResponse) {};
}
@ -20,16 +20,36 @@ message LookupResponse {
// WatchRequest is made to Watch Router
message WatchRequest {}
// EventType is TableEvent type
// AdvertType defines the type of advert
enum AdvertType {
AdvertAnnounce = 0;
AdvertUpdate = 1;
}
// Advert is router advertsement streamed by Watch
message Advert {
// id of the advertising router
string id = 1;
// type of advertisement
AdvertType type = 2;
// unix timestamp of the advertisement
int64 timestamp = 3;
// TTL of the Advert
int64 ttl = 4;
// events is a list of advertised events
repeated Event events = 5;
}
// EventType defines the type of event
enum EventType {
Create = 0;
Delete = 1;
Update = 2;
}
// TableEvent is streamed by WatchRequest
message TableEvent {
// time of table event
// Event is routing table event
message Event {
// type of event
EventType type = 1;
// unix timestamp of event
int64 timestamp = 2;