diff --git a/notes/examples.json b/notes/examples.json index ca262f3..dd5c1fc 100644 --- a/notes/examples.json +++ b/notes/examples.json @@ -90,7 +90,7 @@ } } }], - "subscribe": [{ + "events": [{ "title": "Subscribe to events", "description": "Subscribe to note change events", "run_check": false, diff --git a/notes/handler/notes.go b/notes/handler/notes.go index 795c92d..99ec246 100644 --- a/notes/handler/notes.go +++ b/notes/handler/notes.go @@ -76,7 +76,7 @@ func (h *Notes) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Creat Topic: "notes", Message: newMessage(map[string]interface{}{ "event": "create", - "note": note, + "note": note, }), }) @@ -162,7 +162,7 @@ func (h *Notes) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat Topic: "notes", Message: newMessage(map[string]interface{}{ "event": "update", - "note": note, + "note": note, }), }) @@ -171,7 +171,7 @@ func (h *Notes) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat 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{ Topic: "notes", }) @@ -197,7 +197,7 @@ func (h *Notes) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream continue } - rsp := new(pb.SubscribeResponse) + rsp := new(pb.EventsResponse) if err := json.Unmarshal(v, rsp); err != nil { continue @@ -256,7 +256,7 @@ func (h *Notes) Delete(ctx context.Context, req *pb.DeleteRequest, rsp *pb.Delet Topic: "notes", Message: newMessage(map[string]interface{}{ "event": "delete", - "note": note, + "note": note, }), }) diff --git a/notes/proto/notes.pb.go b/notes/proto/notes.pb.go index 00f5294..3d8c5cd 100644 --- a/notes/proto/notes.pb.go +++ b/notes/proto/notes.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.27.1 // protoc v3.15.6 // source: proto/notes.proto @@ -586,7 +586,7 @@ func (x *ListResponse) GetNotes() []*Note { } // Specify the note to events -type SubscribeRequest struct { +type EventsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -595,8 +595,8 @@ type SubscribeRequest struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *SubscribeRequest) Reset() { - *x = SubscribeRequest{} +func (x *EventsRequest) Reset() { + *x = EventsRequest{} if protoimpl.UnsafeEnabled { mi := &file_proto_notes_proto_msgTypes[11] 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) } -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] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -622,31 +622,31 @@ func (x *SubscribeRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead. -func (*SubscribeRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use EventsRequest.ProtoReflect.Descriptor instead. +func (*EventsRequest) Descriptor() ([]byte, []int) { return file_proto_notes_proto_rawDescGZIP(), []int{11} } -func (x *SubscribeRequest) GetId() string { +func (x *EventsRequest) GetId() string { if x != nil { return x.Id } return "" } -type SubscribeResponse struct { +type EventsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache 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"` // the note which the operation occured on Note *Note `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` } -func (x *SubscribeResponse) Reset() { - *x = SubscribeResponse{} +func (x *EventsResponse) Reset() { + *x = EventsResponse{} if protoimpl.UnsafeEnabled { mi := &file_proto_notes_proto_msgTypes[12] 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) } -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] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -672,19 +672,19 @@ func (x *SubscribeResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead. -func (*SubscribeResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use EventsResponse.ProtoReflect.Descriptor instead. +func (*EventsResponse) Descriptor() ([]byte, []int) { return file_proto_notes_proto_rawDescGZIP(), []int{12} } -func (x *SubscribeResponse) GetEvent() string { +func (x *EventsResponse) GetEvent() string { if x != nil { return x.Event } return "" } -func (x *SubscribeResponse) GetNote() *Note { +func (x *EventsResponse) GetNote() *Note { if x != nil { 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, 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, - 0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x22, 0x0a, 0x10, 0x53, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x4a, 0x0a, - 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, - 0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x32, 0xd0, 0x02, 0x0a, 0x05, 0x4e, 0x6f, - 0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x6e, 0x6f, - 0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x14, - 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x52, - 0x65, 0x61, 0x64, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, - 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, - 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, - 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x09, 0x53, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x17, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, - 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x0f, 0x5a, 0x0d, - 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x1f, 0x0a, 0x0d, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x47, 0x0a, 0x0e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, + 0x6f, 0x74, 0x65, 0x32, 0xc7, 0x02, 0x0a, 0x05, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a, + 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, + 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, + 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, + 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x12, 0x2e, + 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, + 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, + 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x14, + 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x0f, 0x5a, + 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -777,19 +776,19 @@ func file_proto_notes_proto_rawDescGZIP() []byte { var file_proto_notes_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_proto_notes_proto_goTypes = []interface{}{ - (*Note)(nil), // 0: notes.Note - (*CreateRequest)(nil), // 1: notes.CreateRequest - (*CreateResponse)(nil), // 2: notes.CreateResponse - (*ReadRequest)(nil), // 3: notes.ReadRequest - (*ReadResponse)(nil), // 4: notes.ReadResponse - (*UpdateRequest)(nil), // 5: notes.UpdateRequest - (*UpdateResponse)(nil), // 6: notes.UpdateResponse - (*DeleteRequest)(nil), // 7: notes.DeleteRequest - (*DeleteResponse)(nil), // 8: notes.DeleteResponse - (*ListRequest)(nil), // 9: notes.ListRequest - (*ListResponse)(nil), // 10: notes.ListResponse - (*SubscribeRequest)(nil), // 11: notes.SubscribeRequest - (*SubscribeResponse)(nil), // 12: notes.SubscribeResponse + (*Note)(nil), // 0: notes.Note + (*CreateRequest)(nil), // 1: notes.CreateRequest + (*CreateResponse)(nil), // 2: notes.CreateResponse + (*ReadRequest)(nil), // 3: notes.ReadRequest + (*ReadResponse)(nil), // 4: notes.ReadResponse + (*UpdateRequest)(nil), // 5: notes.UpdateRequest + (*UpdateResponse)(nil), // 6: notes.UpdateResponse + (*DeleteRequest)(nil), // 7: notes.DeleteRequest + (*DeleteResponse)(nil), // 8: notes.DeleteResponse + (*ListRequest)(nil), // 9: notes.ListRequest + (*ListResponse)(nil), // 10: notes.ListResponse + (*EventsRequest)(nil), // 11: notes.EventsRequest + (*EventsResponse)(nil), // 12: notes.EventsResponse } var file_proto_notes_proto_depIdxs = []int32{ 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, // 4: notes.DeleteResponse.note: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 1, // 8: notes.Notes.Create:input_type -> notes.CreateRequest 3, // 9: notes.Notes.Read:input_type -> notes.ReadRequest 7, // 10: notes.Notes.Delete:input_type -> notes.DeleteRequest 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 2, // 14: notes.Notes.Create:output_type -> notes.CreateResponse 4, // 15: notes.Notes.Read:output_type -> notes.ReadResponse 8, // 16: notes.Notes.Delete:output_type -> notes.DeleteResponse 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 7, // [7:13] is the sub-list for method input_type 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{} { - switch v := v.(*SubscribeRequest); i { + switch v := v.(*EventsRequest); i { case 0: return &v.state 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{} { - switch v := v.(*SubscribeResponse); i { + switch v := v.(*EventsResponse); i { case 0: return &v.state case 1: diff --git a/notes/proto/notes.pb.micro.go b/notes/proto/notes.pb.micro.go index 3cfabdb..bbb6bb6 100644 --- a/notes/proto/notes.pb.micro.go +++ b/notes/proto/notes.pb.micro.go @@ -47,7 +47,7 @@ type NotesService interface { Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, 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 { @@ -112,8 +112,8 @@ func (c *notesService) Update(ctx context.Context, in *UpdateRequest, opts ...cl return out, nil } -func (c *notesService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Notes_SubscribeService, error) { - req := c.c.NewRequest(c.name, "Notes.Subscribe", &SubscribeRequest{}) +func (c *notesService) Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Notes_EventsService, error) { + req := c.c.NewRequest(c.name, "Notes.Events", &EventsRequest{}) stream, err := c.c.Stream(ctx, req, opts...) if err != nil { return nil, err @@ -121,39 +121,39 @@ func (c *notesService) Subscribe(ctx context.Context, in *SubscribeRequest, opts if err := stream.Send(in); err != nil { return nil, err } - return ¬esServiceSubscribe{stream}, nil + return ¬esServiceEvents{stream}, nil } -type Notes_SubscribeService interface { +type Notes_EventsService interface { Context() context.Context SendMsg(interface{}) error RecvMsg(interface{}) error Close() error - Recv() (*SubscribeResponse, error) + Recv() (*EventsResponse, error) } -type notesServiceSubscribe struct { +type notesServiceEvents struct { stream client.Stream } -func (x *notesServiceSubscribe) Close() error { +func (x *notesServiceEvents) Close() error { return x.stream.Close() } -func (x *notesServiceSubscribe) Context() context.Context { +func (x *notesServiceEvents) Context() context.Context { return x.stream.Context() } -func (x *notesServiceSubscribe) SendMsg(m interface{}) error { +func (x *notesServiceEvents) SendMsg(m interface{}) error { return x.stream.Send(m) } -func (x *notesServiceSubscribe) RecvMsg(m interface{}) error { +func (x *notesServiceEvents) RecvMsg(m interface{}) error { return x.stream.Recv(m) } -func (x *notesServiceSubscribe) Recv() (*SubscribeResponse, error) { - m := new(SubscribeResponse) +func (x *notesServiceEvents) Recv() (*EventsResponse, error) { + m := new(EventsResponse) err := x.stream.Recv(m) if err != nil { return nil, err @@ -169,7 +169,7 @@ type NotesHandler interface { Read(context.Context, *ReadRequest, *ReadResponse) error Delete(context.Context, *DeleteRequest, *DeleteResponse) 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 { @@ -179,7 +179,7 @@ func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.Han Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) 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 { notes @@ -212,42 +212,42 @@ func (h *notesHandler) Update(ctx context.Context, in *UpdateRequest, out *Updat return h.NotesHandler.Update(ctx, in, out) } -func (h *notesHandler) Subscribe(ctx context.Context, stream server.Stream) error { - m := new(SubscribeRequest) +func (h *notesHandler) Events(ctx context.Context, stream server.Stream) error { + m := new(EventsRequest) if err := stream.Recv(m); err != nil { return err } - return h.NotesHandler.Subscribe(ctx, m, ¬esSubscribeStream{stream}) + return h.NotesHandler.Events(ctx, m, ¬esEventsStream{stream}) } -type Notes_SubscribeStream interface { +type Notes_EventsStream interface { Context() context.Context SendMsg(interface{}) error RecvMsg(interface{}) error Close() error - Send(*SubscribeResponse) error + Send(*EventsResponse) error } -type notesSubscribeStream struct { +type notesEventsStream struct { stream server.Stream } -func (x *notesSubscribeStream) Close() error { +func (x *notesEventsStream) Close() error { return x.stream.Close() } -func (x *notesSubscribeStream) Context() context.Context { +func (x *notesEventsStream) Context() context.Context { return x.stream.Context() } -func (x *notesSubscribeStream) SendMsg(m interface{}) error { +func (x *notesEventsStream) SendMsg(m interface{}) error { return x.stream.Send(m) } -func (x *notesSubscribeStream) RecvMsg(m interface{}) error { +func (x *notesEventsStream) RecvMsg(m interface{}) error { return x.stream.Recv(m) } -func (x *notesSubscribeStream) Send(m *SubscribeResponse) error { +func (x *notesEventsStream) Send(m *EventsResponse) error { return x.stream.Send(m) } diff --git a/notes/proto/notes.proto b/notes/proto/notes.proto index 0b38bdd..f3a7da8 100644 --- a/notes/proto/notes.proto +++ b/notes/proto/notes.proto @@ -10,7 +10,7 @@ service Notes { rpc Read(ReadRequest) returns (ReadResponse); rpc Delete(DeleteRequest) returns (DeleteResponse); rpc Update(UpdateRequest) returns (UpdateResponse); - rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse); + rpc Events(EventsRequest) returns (stream EventsResponse); } message Note { @@ -78,12 +78,12 @@ message ListResponse { } // Specify the note to events -message SubscribeRequest { +message EventsRequest { // optionally specify a note id string id = 1; } -message SubscribeResponse { +message EventsResponse { // the event which occured; create, delete, update string event = 1; // the note which the operation occured on