rename notes subscribe to events

This commit is contained in:
Asim Aslam
2021-11-02 11:45:52 +00:00
parent 911f33085a
commit a25d0482b3
5 changed files with 104 additions and 105 deletions

View File

@@ -90,7 +90,7 @@
} }
} }
}], }],
"subscribe": [{ "events": [{
"title": "Subscribe to events", "title": "Subscribe to events",
"description": "Subscribe to note change events", "description": "Subscribe to note change events",
"run_check": false, "run_check": false,

View File

@@ -171,7 +171,7 @@ func (h *Notes) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat
return nil return nil
} }
func (h *Notes) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream pb.Notes_SubscribeStream) error { func (h *Notes) Events(ctx context.Context, req *pb.EventsRequest, stream pb.Notes_EventsStream) error {
backendStream, err := h.Stream.Subscribe(ctx, &streamPb.SubscribeRequest{ backendStream, err := h.Stream.Subscribe(ctx, &streamPb.SubscribeRequest{
Topic: "notes", Topic: "notes",
}) })
@@ -197,7 +197,7 @@ func (h *Notes) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream
continue continue
} }
rsp := new(pb.SubscribeResponse) rsp := new(pb.EventsResponse)
if err := json.Unmarshal(v, rsp); err != nil { if err := json.Unmarshal(v, rsp); err != nil {
continue continue

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0 // protoc-gen-go v1.27.1
// protoc v3.15.6 // protoc v3.15.6
// source: proto/notes.proto // source: proto/notes.proto
@@ -586,7 +586,7 @@ func (x *ListResponse) GetNotes() []*Note {
} }
// Specify the note to events // Specify the note to events
type SubscribeRequest struct { type EventsRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@@ -595,8 +595,8 @@ type SubscribeRequest struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
} }
func (x *SubscribeRequest) Reset() { func (x *EventsRequest) Reset() {
*x = SubscribeRequest{} *x = EventsRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_notes_proto_msgTypes[11] mi := &file_proto_notes_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -604,13 +604,13 @@ func (x *SubscribeRequest) Reset() {
} }
} }
func (x *SubscribeRequest) String() string { func (x *EventsRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*SubscribeRequest) ProtoMessage() {} func (*EventsRequest) ProtoMessage() {}
func (x *SubscribeRequest) ProtoReflect() protoreflect.Message { func (x *EventsRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_notes_proto_msgTypes[11] mi := &file_proto_notes_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -622,31 +622,31 @@ func (x *SubscribeRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead. // Deprecated: Use EventsRequest.ProtoReflect.Descriptor instead.
func (*SubscribeRequest) Descriptor() ([]byte, []int) { func (*EventsRequest) Descriptor() ([]byte, []int) {
return file_proto_notes_proto_rawDescGZIP(), []int{11} return file_proto_notes_proto_rawDescGZIP(), []int{11}
} }
func (x *SubscribeRequest) GetId() string { func (x *EventsRequest) GetId() string {
if x != nil { if x != nil {
return x.Id return x.Id
} }
return "" return ""
} }
type SubscribeResponse struct { type EventsResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// the event which occured; created, deleted, updated // the event which occured; create, delete, update
Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
// the note which the operation occured on // the note which the operation occured on
Note *Note `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` Note *Note `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"`
} }
func (x *SubscribeResponse) Reset() { func (x *EventsResponse) Reset() {
*x = SubscribeResponse{} *x = EventsResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_proto_notes_proto_msgTypes[12] mi := &file_proto_notes_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -654,13 +654,13 @@ func (x *SubscribeResponse) Reset() {
} }
} }
func (x *SubscribeResponse) String() string { func (x *EventsResponse) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*SubscribeResponse) ProtoMessage() {} func (*EventsResponse) ProtoMessage() {}
func (x *SubscribeResponse) ProtoReflect() protoreflect.Message { func (x *EventsResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_notes_proto_msgTypes[12] mi := &file_proto_notes_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -672,19 +672,19 @@ func (x *SubscribeResponse) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead. // Deprecated: Use EventsResponse.ProtoReflect.Descriptor instead.
func (*SubscribeResponse) Descriptor() ([]byte, []int) { func (*EventsResponse) Descriptor() ([]byte, []int) {
return file_proto_notes_proto_rawDescGZIP(), []int{12} return file_proto_notes_proto_rawDescGZIP(), []int{12}
} }
func (x *SubscribeResponse) GetEvent() string { func (x *EventsResponse) GetEvent() string {
if x != nil { if x != nil {
return x.Event return x.Event
} }
return "" return ""
} }
func (x *SubscribeResponse) GetNote() *Note { func (x *EventsResponse) GetNote() *Note {
if x != nil { if x != nil {
return x.Note return x.Note
} }
@@ -730,37 +730,36 @@ var file_proto_notes_proto_rawDesc = []byte{
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, 0x6f, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, 0x6f,
0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x22, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x1f, 0x0a, 0x0d, 0x45, 0x76, 0x65,
0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x4a, 0x0a, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x47, 0x0a, 0x0e, 0x45, 0x76,
0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65,
0x09, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e,
0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x32, 0xd0, 0x02, 0x0a, 0x05, 0x4e, 0x6f, 0x6f, 0x74, 0x65, 0x32, 0xc7, 0x02, 0x0a, 0x05, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a,
0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69,
0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65,
0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73,
0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x52, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x12, 0x2e,
0x65, 0x61, 0x64, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65,
0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44,
0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a,
0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e,
0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e,
0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x09, 0x53, 0x75, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x14,
0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x17, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71,
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65,
0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x0f, 0x5a,
0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x0f, 0x5a, 0x0d, 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x62, 0x06,
0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x62, 0x06, 0x70, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -788,8 +787,8 @@ var file_proto_notes_proto_goTypes = []interface{}{
(*DeleteResponse)(nil), // 8: notes.DeleteResponse (*DeleteResponse)(nil), // 8: notes.DeleteResponse
(*ListRequest)(nil), // 9: notes.ListRequest (*ListRequest)(nil), // 9: notes.ListRequest
(*ListResponse)(nil), // 10: notes.ListResponse (*ListResponse)(nil), // 10: notes.ListResponse
(*SubscribeRequest)(nil), // 11: notes.SubscribeRequest (*EventsRequest)(nil), // 11: notes.EventsRequest
(*SubscribeResponse)(nil), // 12: notes.SubscribeResponse (*EventsResponse)(nil), // 12: notes.EventsResponse
} }
var file_proto_notes_proto_depIdxs = []int32{ var file_proto_notes_proto_depIdxs = []int32{
0, // 0: notes.CreateResponse.note:type_name -> notes.Note 0, // 0: notes.CreateResponse.note:type_name -> notes.Note
@@ -798,19 +797,19 @@ var file_proto_notes_proto_depIdxs = []int32{
0, // 3: notes.UpdateResponse.note:type_name -> notes.Note 0, // 3: notes.UpdateResponse.note:type_name -> notes.Note
0, // 4: notes.DeleteResponse.note:type_name -> notes.Note 0, // 4: notes.DeleteResponse.note:type_name -> notes.Note
0, // 5: notes.ListResponse.notes:type_name -> notes.Note 0, // 5: notes.ListResponse.notes:type_name -> notes.Note
0, // 6: notes.SubscribeResponse.note:type_name -> notes.Note 0, // 6: notes.EventsResponse.note:type_name -> notes.Note
9, // 7: notes.Notes.List:input_type -> notes.ListRequest 9, // 7: notes.Notes.List:input_type -> notes.ListRequest
1, // 8: notes.Notes.Create:input_type -> notes.CreateRequest 1, // 8: notes.Notes.Create:input_type -> notes.CreateRequest
3, // 9: notes.Notes.Read:input_type -> notes.ReadRequest 3, // 9: notes.Notes.Read:input_type -> notes.ReadRequest
7, // 10: notes.Notes.Delete:input_type -> notes.DeleteRequest 7, // 10: notes.Notes.Delete:input_type -> notes.DeleteRequest
5, // 11: notes.Notes.Update:input_type -> notes.UpdateRequest 5, // 11: notes.Notes.Update:input_type -> notes.UpdateRequest
11, // 12: notes.Notes.Subscribe:input_type -> notes.SubscribeRequest 11, // 12: notes.Notes.Events:input_type -> notes.EventsRequest
10, // 13: notes.Notes.List:output_type -> notes.ListResponse 10, // 13: notes.Notes.List:output_type -> notes.ListResponse
2, // 14: notes.Notes.Create:output_type -> notes.CreateResponse 2, // 14: notes.Notes.Create:output_type -> notes.CreateResponse
4, // 15: notes.Notes.Read:output_type -> notes.ReadResponse 4, // 15: notes.Notes.Read:output_type -> notes.ReadResponse
8, // 16: notes.Notes.Delete:output_type -> notes.DeleteResponse 8, // 16: notes.Notes.Delete:output_type -> notes.DeleteResponse
6, // 17: notes.Notes.Update:output_type -> notes.UpdateResponse 6, // 17: notes.Notes.Update:output_type -> notes.UpdateResponse
12, // 18: notes.Notes.Subscribe:output_type -> notes.SubscribeResponse 12, // 18: notes.Notes.Events:output_type -> notes.EventsResponse
13, // [13:19] is the sub-list for method output_type 13, // [13:19] is the sub-list for method output_type
7, // [7:13] is the sub-list for method input_type 7, // [7:13] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name 7, // [7:7] is the sub-list for extension type_name
@@ -957,7 +956,7 @@ func file_proto_notes_proto_init() {
} }
} }
file_proto_notes_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { file_proto_notes_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeRequest); i { switch v := v.(*EventsRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -969,7 +968,7 @@ func file_proto_notes_proto_init() {
} }
} }
file_proto_notes_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { file_proto_notes_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeResponse); i { switch v := v.(*EventsResponse); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:

View File

@@ -47,7 +47,7 @@ type NotesService interface {
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Notes_SubscribeService, error) Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Notes_EventsService, error)
} }
type notesService struct { type notesService struct {
@@ -112,8 +112,8 @@ func (c *notesService) Update(ctx context.Context, in *UpdateRequest, opts ...cl
return out, nil return out, nil
} }
func (c *notesService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Notes_SubscribeService, error) { func (c *notesService) Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Notes_EventsService, error) {
req := c.c.NewRequest(c.name, "Notes.Subscribe", &SubscribeRequest{}) req := c.c.NewRequest(c.name, "Notes.Events", &EventsRequest{})
stream, err := c.c.Stream(ctx, req, opts...) stream, err := c.c.Stream(ctx, req, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -121,39 +121,39 @@ func (c *notesService) Subscribe(ctx context.Context, in *SubscribeRequest, opts
if err := stream.Send(in); err != nil { if err := stream.Send(in); err != nil {
return nil, err return nil, err
} }
return &notesServiceSubscribe{stream}, nil return &notesServiceEvents{stream}, nil
} }
type Notes_SubscribeService interface { type Notes_EventsService interface {
Context() context.Context Context() context.Context
SendMsg(interface{}) error SendMsg(interface{}) error
RecvMsg(interface{}) error RecvMsg(interface{}) error
Close() error Close() error
Recv() (*SubscribeResponse, error) Recv() (*EventsResponse, error)
} }
type notesServiceSubscribe struct { type notesServiceEvents struct {
stream client.Stream stream client.Stream
} }
func (x *notesServiceSubscribe) Close() error { func (x *notesServiceEvents) Close() error {
return x.stream.Close() return x.stream.Close()
} }
func (x *notesServiceSubscribe) Context() context.Context { func (x *notesServiceEvents) Context() context.Context {
return x.stream.Context() return x.stream.Context()
} }
func (x *notesServiceSubscribe) SendMsg(m interface{}) error { func (x *notesServiceEvents) SendMsg(m interface{}) error {
return x.stream.Send(m) return x.stream.Send(m)
} }
func (x *notesServiceSubscribe) RecvMsg(m interface{}) error { func (x *notesServiceEvents) RecvMsg(m interface{}) error {
return x.stream.Recv(m) return x.stream.Recv(m)
} }
func (x *notesServiceSubscribe) Recv() (*SubscribeResponse, error) { func (x *notesServiceEvents) Recv() (*EventsResponse, error) {
m := new(SubscribeResponse) m := new(EventsResponse)
err := x.stream.Recv(m) err := x.stream.Recv(m)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -169,7 +169,7 @@ type NotesHandler interface {
Read(context.Context, *ReadRequest, *ReadResponse) error Read(context.Context, *ReadRequest, *ReadResponse) error
Delete(context.Context, *DeleteRequest, *DeleteResponse) error Delete(context.Context, *DeleteRequest, *DeleteResponse) error
Update(context.Context, *UpdateRequest, *UpdateResponse) error Update(context.Context, *UpdateRequest, *UpdateResponse) error
Subscribe(context.Context, *SubscribeRequest, Notes_SubscribeStream) error Events(context.Context, *EventsRequest, Notes_EventsStream) error
} }
func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.HandlerOption) error { func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.HandlerOption) error {
@@ -179,7 +179,7 @@ func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.Han
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
Subscribe(ctx context.Context, stream server.Stream) error Events(ctx context.Context, stream server.Stream) error
} }
type Notes struct { type Notes struct {
notes notes
@@ -212,42 +212,42 @@ func (h *notesHandler) Update(ctx context.Context, in *UpdateRequest, out *Updat
return h.NotesHandler.Update(ctx, in, out) return h.NotesHandler.Update(ctx, in, out)
} }
func (h *notesHandler) Subscribe(ctx context.Context, stream server.Stream) error { func (h *notesHandler) Events(ctx context.Context, stream server.Stream) error {
m := new(SubscribeRequest) m := new(EventsRequest)
if err := stream.Recv(m); err != nil { if err := stream.Recv(m); err != nil {
return err return err
} }
return h.NotesHandler.Subscribe(ctx, m, &notesSubscribeStream{stream}) return h.NotesHandler.Events(ctx, m, &notesEventsStream{stream})
} }
type Notes_SubscribeStream interface { type Notes_EventsStream interface {
Context() context.Context Context() context.Context
SendMsg(interface{}) error SendMsg(interface{}) error
RecvMsg(interface{}) error RecvMsg(interface{}) error
Close() error Close() error
Send(*SubscribeResponse) error Send(*EventsResponse) error
} }
type notesSubscribeStream struct { type notesEventsStream struct {
stream server.Stream stream server.Stream
} }
func (x *notesSubscribeStream) Close() error { func (x *notesEventsStream) Close() error {
return x.stream.Close() return x.stream.Close()
} }
func (x *notesSubscribeStream) Context() context.Context { func (x *notesEventsStream) Context() context.Context {
return x.stream.Context() return x.stream.Context()
} }
func (x *notesSubscribeStream) SendMsg(m interface{}) error { func (x *notesEventsStream) SendMsg(m interface{}) error {
return x.stream.Send(m) return x.stream.Send(m)
} }
func (x *notesSubscribeStream) RecvMsg(m interface{}) error { func (x *notesEventsStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m) return x.stream.Recv(m)
} }
func (x *notesSubscribeStream) Send(m *SubscribeResponse) error { func (x *notesEventsStream) Send(m *EventsResponse) error {
return x.stream.Send(m) return x.stream.Send(m)
} }

View File

@@ -10,7 +10,7 @@ service Notes {
rpc Read(ReadRequest) returns (ReadResponse); rpc Read(ReadRequest) returns (ReadResponse);
rpc Delete(DeleteRequest) returns (DeleteResponse); rpc Delete(DeleteRequest) returns (DeleteResponse);
rpc Update(UpdateRequest) returns (UpdateResponse); rpc Update(UpdateRequest) returns (UpdateResponse);
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse); rpc Events(EventsRequest) returns (stream EventsResponse);
} }
message Note { message Note {
@@ -78,12 +78,12 @@ message ListResponse {
} }
// Specify the note to events // Specify the note to events
message SubscribeRequest { message EventsRequest {
// optionally specify a note id // optionally specify a note id
string id = 1; string id = 1;
} }
message SubscribeResponse { message EventsResponse {
// the event which occured; create, delete, update // the event which occured; create, delete, update
string event = 1; string event = 1;
// the note which the operation occured on // the note which the operation occured on