feat: add edit note rpc method

pull/1/head
sundowndev 2024-02-27 19:09:22 +04:00
parent e4435e0ec2
commit ceb9463a1b
5 changed files with 488 additions and 256 deletions

View File

@ -10,6 +10,7 @@ import (
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
@ -21,185 +22,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ListNotesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ListNotesRequest) Reset() {
*x = ListNotesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListNotesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListNotesRequest) ProtoMessage() {}
func (x *ListNotesRequest) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListNotesRequest.ProtoReflect.Descriptor instead.
func (*ListNotesRequest) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{0}
}
type ListNotesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *ListNotesResponse) Reset() {
*x = ListNotesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListNotesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListNotesResponse) ProtoMessage() {}
func (x *ListNotesResponse) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListNotesResponse.ProtoReflect.Descriptor instead.
func (*ListNotesResponse) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{1}
}
func (x *ListNotesResponse) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
type AddNoteRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
}
func (x *AddNoteRequest) Reset() {
*x = AddNoteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddNoteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddNoteRequest) ProtoMessage() {}
func (x *AddNoteRequest) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddNoteRequest.ProtoReflect.Descriptor instead.
func (*AddNoteRequest) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{2}
}
func (x *AddNoteRequest) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
type AddNoteResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *AddNoteResponse) Reset() {
*x = AddNoteResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddNoteResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddNoteResponse) ProtoMessage() {}
func (x *AddNoteResponse) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddNoteResponse.ProtoReflect.Descriptor instead.
func (*AddNoteResponse) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{3}
}
func (x *AddNoteResponse) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
type Note struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -213,7 +35,7 @@ type Note struct {
func (x *Note) Reset() {
*x = Note{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[4]
mi := &file_notes_v1_notes_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -226,7 +48,7 @@ func (x *Note) String() string {
func (*Note) ProtoMessage() {}
func (x *Note) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[4]
mi := &file_notes_v1_notes_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -239,7 +61,7 @@ func (x *Note) ProtoReflect() protoreflect.Message {
// Deprecated: Use Note.ProtoReflect.Descriptor instead.
func (*Note) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{4}
return file_notes_v1_notes_proto_rawDescGZIP(), []int{0}
}
func (x *Note) GetId() string {
@ -263,50 +85,336 @@ func (x *Note) GetArchived() bool {
return false
}
type ListNotesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ListNotesRequest) Reset() {
*x = ListNotesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListNotesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListNotesRequest) ProtoMessage() {}
func (x *ListNotesRequest) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListNotesRequest.ProtoReflect.Descriptor instead.
func (*ListNotesRequest) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{1}
}
type ListNotesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *ListNotesResponse) Reset() {
*x = ListNotesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListNotesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListNotesResponse) ProtoMessage() {}
func (x *ListNotesResponse) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListNotesResponse.ProtoReflect.Descriptor instead.
func (*ListNotesResponse) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{2}
}
func (x *ListNotesResponse) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
type AddNoteRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
}
func (x *AddNoteRequest) Reset() {
*x = AddNoteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddNoteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddNoteRequest) ProtoMessage() {}
func (x *AddNoteRequest) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddNoteRequest.ProtoReflect.Descriptor instead.
func (*AddNoteRequest) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{3}
}
func (x *AddNoteRequest) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
type AddNoteResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *AddNoteResponse) Reset() {
*x = AddNoteResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddNoteResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddNoteResponse) ProtoMessage() {}
func (x *AddNoteResponse) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddNoteResponse.ProtoReflect.Descriptor instead.
func (*AddNoteResponse) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{4}
}
func (x *AddNoteResponse) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
type EditNoteRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *EditNoteRequest) Reset() {
*x = EditNoteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EditNoteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EditNoteRequest) ProtoMessage() {}
func (x *EditNoteRequest) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EditNoteRequest.ProtoReflect.Descriptor instead.
func (*EditNoteRequest) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{5}
}
func (x *EditNoteRequest) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
type EditNoteResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Note *Note `protobuf:"bytes,1,opt,name=note,proto3" json:"note,omitempty"`
}
func (x *EditNoteResponse) Reset() {
*x = EditNoteResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_notes_v1_notes_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EditNoteResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EditNoteResponse) ProtoMessage() {}
func (x *EditNoteResponse) ProtoReflect() protoreflect.Message {
mi := &file_notes_v1_notes_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EditNoteResponse.ProtoReflect.Descriptor instead.
func (*EditNoteResponse) Descriptor() ([]byte, []int) {
return file_notes_v1_notes_proto_rawDescGZIP(), []int{6}
}
func (x *EditNoteResponse) GetNote() *Note {
if x != nil {
return x.Note
}
return nil
}
var File_notes_v1_notes_proto protoreflect.FileDescriptor
var file_notes_v1_notes_proto_rawDesc = []byte{
0x0a, 0x14, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x6f, 0x74, 0x65, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31,
0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x12, 0x0a,
0x10, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x22, 0x37, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
0x4e, 0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x22, 0x26, 0x0a, 0x0e, 0x41, 0x64,
0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05,
0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74,
0x6c, 0x65, 0x22, 0x35, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4e,
0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x22, 0x5d, 0x0a, 0x04, 0x4e, 0x6f, 0x74,
0x65, 0x12, 0x18, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xba,
0x48, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x74,
0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xba, 0x48, 0x06, 0x72,
0x04, 0x10, 0x01, 0x18, 0x32, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08,
0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x32, 0x9a, 0x01, 0x0a, 0x0c, 0x4e, 0x6f, 0x74,
0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x4c, 0x69, 0x73,
0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76,
0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x30, 0x01, 0x12, 0x40, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x12, 0x18,
0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73,
0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x6e, 0x6f,
0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x73, 0x75, 0x6e, 0x64, 0x6f, 0x77, 0x6e, 0x64, 0x65, 0x76, 0x2f, 0x67, 0x72, 0x70, 0x63,
0x2d, 0x61, 0x70, 0x69, 0x2d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x6e, 0x6f, 0x74, 0x65,
0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4e, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x4e, 0x6f, 0x74, 0x65,
0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2,
0x02, 0x14, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x3a, 0x3a,
0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65,
0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5d, 0x0a, 0x04, 0x4e, 0x6f,
0x74, 0x65, 0x12, 0x18, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08,
0xba, 0x48, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x05,
0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xba, 0x48, 0x06,
0x72, 0x04, 0x10, 0x01, 0x18, 0x32, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1a, 0x0a,
0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52,
0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73,
0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x37, 0x0a,
0x11, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x74, 0x65,
0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x22, 0x26, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x35,
0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x74, 0x65, 0x52,
0x04, 0x6e, 0x6f, 0x74, 0x65, 0x22, 0x35, 0x0a, 0x0f, 0x45, 0x64, 0x69, 0x74, 0x4e, 0x6f, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76,
0x31, 0x2e, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x22, 0x36, 0x0a, 0x10,
0x45, 0x64, 0x69, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x22, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e,
0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x04,
0x6e, 0x6f, 0x74, 0x65, 0x32, 0xdf, 0x01, 0x0a, 0x0c, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x74,
0x65, 0x73, 0x12, 0x1a, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b,
0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f,
0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12,
0x40, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x6e, 0x6f, 0x74,
0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
0x41, 0x64, 0x64, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x43, 0x0a, 0x08, 0x45, 0x64, 0x69, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x12, 0x19, 0x2e,
0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x4e, 0x6f, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x73,
0x2e, 0x76, 0x31, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x6e,
0x6f, 0x74, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x50, 0x72,
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x73, 0x75, 0x6e, 0x64, 0x6f, 0x77, 0x6e, 0x64, 0x65, 0x76, 0x2f, 0x67, 0x72, 0x70,
0x63, 0x2d, 0x61, 0x70, 0x69, 0x2d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2f, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x6e, 0x6f, 0x74,
0x65, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4e, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x4e, 0x6f, 0x74,
0x65, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x5c, 0x56, 0x31,
0xe2, 0x02, 0x14, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x3a,
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -321,26 +429,32 @@ func file_notes_v1_notes_proto_rawDescGZIP() []byte {
return file_notes_v1_notes_proto_rawDescData
}
var file_notes_v1_notes_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_notes_v1_notes_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_notes_v1_notes_proto_goTypes = []interface{}{
(*ListNotesRequest)(nil), // 0: notes.v1.ListNotesRequest
(*ListNotesResponse)(nil), // 1: notes.v1.ListNotesResponse
(*AddNoteRequest)(nil), // 2: notes.v1.AddNoteRequest
(*AddNoteResponse)(nil), // 3: notes.v1.AddNoteResponse
(*Note)(nil), // 4: notes.v1.Note
(*Note)(nil), // 0: notes.v1.Note
(*ListNotesRequest)(nil), // 1: notes.v1.ListNotesRequest
(*ListNotesResponse)(nil), // 2: notes.v1.ListNotesResponse
(*AddNoteRequest)(nil), // 3: notes.v1.AddNoteRequest
(*AddNoteResponse)(nil), // 4: notes.v1.AddNoteResponse
(*EditNoteRequest)(nil), // 5: notes.v1.EditNoteRequest
(*EditNoteResponse)(nil), // 6: notes.v1.EditNoteResponse
}
var file_notes_v1_notes_proto_depIdxs = []int32{
4, // 0: notes.v1.ListNotesResponse.note:type_name -> notes.v1.Note
4, // 1: notes.v1.AddNoteResponse.note:type_name -> notes.v1.Note
0, // 2: notes.v1.NotesService.ListNotes:input_type -> notes.v1.ListNotesRequest
2, // 3: notes.v1.NotesService.AddNote:input_type -> notes.v1.AddNoteRequest
1, // 4: notes.v1.NotesService.ListNotes:output_type -> notes.v1.ListNotesResponse
3, // 5: notes.v1.NotesService.AddNote:output_type -> notes.v1.AddNoteResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
0, // 0: notes.v1.ListNotesResponse.note:type_name -> notes.v1.Note
0, // 1: notes.v1.AddNoteResponse.note:type_name -> notes.v1.Note
0, // 2: notes.v1.EditNoteRequest.note:type_name -> notes.v1.Note
0, // 3: notes.v1.EditNoteResponse.note:type_name -> notes.v1.Note
1, // 4: notes.v1.NotesService.ListNotes:input_type -> notes.v1.ListNotesRequest
3, // 5: notes.v1.NotesService.AddNote:input_type -> notes.v1.AddNoteRequest
5, // 6: notes.v1.NotesService.EditNote:input_type -> notes.v1.EditNoteRequest
2, // 7: notes.v1.NotesService.ListNotes:output_type -> notes.v1.ListNotesResponse
4, // 8: notes.v1.NotesService.AddNote:output_type -> notes.v1.AddNoteResponse
6, // 9: notes.v1.NotesService.EditNote:output_type -> notes.v1.EditNoteResponse
7, // [7:10] is the sub-list for method output_type
4, // [4:7] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_notes_v1_notes_proto_init() }
@ -350,7 +464,7 @@ func file_notes_v1_notes_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_notes_v1_notes_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListNotesRequest); i {
switch v := v.(*Note); i {
case 0:
return &v.state
case 1:
@ -362,7 +476,7 @@ func file_notes_v1_notes_proto_init() {
}
}
file_notes_v1_notes_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListNotesResponse); i {
switch v := v.(*ListNotesRequest); i {
case 0:
return &v.state
case 1:
@ -374,7 +488,7 @@ func file_notes_v1_notes_proto_init() {
}
}
file_notes_v1_notes_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddNoteRequest); i {
switch v := v.(*ListNotesResponse); i {
case 0:
return &v.state
case 1:
@ -386,7 +500,7 @@ func file_notes_v1_notes_proto_init() {
}
}
file_notes_v1_notes_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddNoteResponse); i {
switch v := v.(*AddNoteRequest); i {
case 0:
return &v.state
case 1:
@ -398,7 +512,31 @@ func file_notes_v1_notes_proto_init() {
}
}
file_notes_v1_notes_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Note); i {
switch v := v.(*AddNoteResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_notes_v1_notes_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EditNoteRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_notes_v1_notes_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EditNoteResponse); i {
case 0:
return &v.state
case 1:
@ -416,7 +554,7 @@ func file_notes_v1_notes_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_notes_v1_notes_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -7,7 +7,14 @@ import "buf/validate/validate.proto";
service NotesService {
rpc ListNotes(ListNotesRequest) returns (stream ListNotesResponse) {};
rpc AddNote(AddNoteRequest) returns (AddNoteResponse) {};
// rpc ArchiveNote(ArchiveNoteRequest) returns (ArchiveNoteResponse) {};
rpc EditNote(EditNoteRequest) returns (EditNoteResponse) {};
// rpc GetNote(GetNoteRequest) returns (GetNoteResponse) {};
}
message Note {
string id = 1 [(buf.validate.field).string.uuid = true];
string title = 2 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 50];
bool archived = 3;
}
message ListNotesRequest {}
@ -24,8 +31,10 @@ message AddNoteResponse {
Note note = 1;
}
message Note {
string id = 1 [(buf.validate.field).string.uuid = true];
string title = 2 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 50];
bool archived = 3;
message EditNoteRequest {
Note note = 1;
}
message EditNoteResponse {
Note note = 1;
}

View File

@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7
const (
NotesService_ListNotes_FullMethodName = "/notes.v1.NotesService/ListNotes"
NotesService_AddNote_FullMethodName = "/notes.v1.NotesService/AddNote"
NotesService_EditNote_FullMethodName = "/notes.v1.NotesService/EditNote"
)
// NotesServiceClient is the client API for NotesService service.
@ -29,6 +30,7 @@ const (
type NotesServiceClient interface {
ListNotes(ctx context.Context, in *ListNotesRequest, opts ...grpc.CallOption) (NotesService_ListNotesClient, error)
AddNote(ctx context.Context, in *AddNoteRequest, opts ...grpc.CallOption) (*AddNoteResponse, error)
EditNote(ctx context.Context, in *EditNoteRequest, opts ...grpc.CallOption) (*EditNoteResponse, error)
}
type notesServiceClient struct {
@ -80,12 +82,22 @@ func (c *notesServiceClient) AddNote(ctx context.Context, in *AddNoteRequest, op
return out, nil
}
func (c *notesServiceClient) EditNote(ctx context.Context, in *EditNoteRequest, opts ...grpc.CallOption) (*EditNoteResponse, error) {
out := new(EditNoteResponse)
err := c.cc.Invoke(ctx, NotesService_EditNote_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// NotesServiceServer is the server API for NotesService service.
// All implementations should embed UnimplementedNotesServiceServer
// for forward compatibility
type NotesServiceServer interface {
ListNotes(*ListNotesRequest, NotesService_ListNotesServer) error
AddNote(context.Context, *AddNoteRequest) (*AddNoteResponse, error)
EditNote(context.Context, *EditNoteRequest) (*EditNoteResponse, error)
}
// UnimplementedNotesServiceServer should be embedded to have forward compatible implementations.
@ -98,6 +110,9 @@ func (UnimplementedNotesServiceServer) ListNotes(*ListNotesRequest, NotesService
func (UnimplementedNotesServiceServer) AddNote(context.Context, *AddNoteRequest) (*AddNoteResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddNote not implemented")
}
func (UnimplementedNotesServiceServer) EditNote(context.Context, *EditNoteRequest) (*EditNoteResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method EditNote not implemented")
}
// UnsafeNotesServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to NotesServiceServer will
@ -149,6 +164,24 @@ func _NotesService_AddNote_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler)
}
func _NotesService_EditNote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EditNoteRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotesServiceServer).EditNote(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotesService_EditNote_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotesServiceServer).EditNote(ctx, req.(*EditNoteRequest))
}
return interceptor(ctx, in, info, handler)
}
// NotesService_ServiceDesc is the grpc.ServiceDesc for NotesService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -160,6 +193,10 @@ var NotesService_ServiceDesc = grpc.ServiceDesc{
MethodName: "AddNote",
Handler: _NotesService_AddNote_Handler,
},
{
MethodName: "EditNote",
Handler: _NotesService_EditNote_Handler,
},
},
Streams: []grpc.StreamDesc{
{

View File

@ -54,7 +54,29 @@ func (s *NotesService) AddNote(_ context.Context, req *notesv1.AddNoteRequest) (
s.notes = append(s.notes, note)
return &notesv1.AddNoteResponse{
Note: note,
}, nil
return &notesv1.AddNoteResponse{Note: note}, nil
}
func (s *NotesService) EditNote(_ context.Context, req *notesv1.EditNoteRequest) (*notesv1.EditNoteResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
editedNote := &notesv1.Note{
Id: req.Note.Id,
Title: req.Note.Title,
Archived: req.Note.Archived,
}
if err := s.validator.Validate(editedNote); err != nil {
return nil, fmt.Errorf("validation failed: %v", err)
}
for i := range s.notes {
if s.notes[i].Id == req.Note.Id {
s.notes[i] = editedNote
break
}
}
return &notesv1.EditNoteResponse{Note: editedNote}, nil
}

View File

@ -52,22 +52,22 @@ func TestNotesService_ListNotes(t *testing.T) {
{
name: "test with few notes",
notes: []*notesv1.Note{
{Title: "test note 1", Archived: false},
{Title: "note 2", Archived: true},
{Title: "note 3", Archived: false},
{Title: "test note 1"},
{Title: "note 2"},
{Title: "note 3"},
},
},
{
name: "test with min_len validation error",
notes: []*notesv1.Note{
{Title: "", Archived: false},
{Title: ""},
},
wantErr: "validation failed: validation error:\n - title: value length must be at least 1 characters [string.min_len]",
},
{
name: "test with max_len validation error",
notes: []*notesv1.Note{
{Title: "this is a super long note title that can trigger a validation error", Archived: false},
{Title: "this is a super long note title that can trigger a validation error"},
},
wantErr: "validation failed: validation error:\n - title: value length must be at most 50 characters [string.max_len]",
},
@ -140,3 +140,29 @@ func TestNotesService_AddNote(t *testing.T) {
assert.Equal(t, "test note", res.Note.Title)
assert.Equal(t, false, res.Note.Archived)
}
func TestNotesService_EditNote(t *testing.T) {
srv, conn, err := newTestServer()
if err != nil {
t.Fatal(err)
}
client := notesv1.NewNotesServiceClient(conn)
defer srv.Close()
defer conn.Close()
res, err := client.AddNote(context.Background(), &notesv1.AddNoteRequest{Title: "test note"})
if err != nil {
t.Fatal(err)
}
res.Note.Title = "january groceries"
res.Note.Archived = true
res2, err := client.EditNote(context.Background(), &notesv1.EditNoteRequest{Note: res.Note})
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "january groceries", res2.Note.Title)
assert.True(t, res2.Note.Archived)
}