From 301f6360720688887d05930f5dc45135ecf6d089 Mon Sep 17 00:00:00 2001 From: soukainna Date: Wed, 1 Feb 2023 09:58:37 +0100 Subject: [PATCH] add logic to store event modification and deleted event --- grpcapi/agenda.pb.go | 274 ++++++++++++++++++++++++++++---------- grpcapi/agenda.proto | 10 +- grpcapi/agenda_grpc.pb.go | 38 +++++- grpcapi/events.go | 2 + grpcapi/events.pb.go | 110 ++++++++------- grpcapi/events.proto | 1 + grpcapi/grpcapi.go | 18 +++ handlers/events.go | 21 +++ storage/events.go | 1 + storage/mongodb.go | 10 ++ storage/storage.go | 1 + 11 files changed, 364 insertions(+), 122 deletions(-) diff --git a/grpcapi/agenda.pb.go b/grpcapi/agenda.pb.go index 8c691ce..ac4ae8f 100644 --- a/grpcapi/agenda.pb.go +++ b/grpcapi/agenda.pb.go @@ -2,17 +2,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.19.4 +// protoc-gen-go v1.28.1 +// protoc v3.12.4 // source: agenda.proto package grpcapi import ( + _struct "github.com/golang/protobuf/ptypes/struct" + timestamp "github.com/golang/protobuf/ptypes/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - structpb "google.golang.org/protobuf/types/known/structpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -311,9 +311,9 @@ type GetEventsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Namespaces []string `protobuf:"bytes,10,rep,name=namespaces,proto3" json:"namespaces,omitempty"` - Mindate *timestamppb.Timestamp `protobuf:"bytes,11,opt,name=mindate,proto3" json:"mindate,omitempty"` - Maxdate *timestamppb.Timestamp `protobuf:"bytes,12,opt,name=maxdate,proto3" json:"maxdate,omitempty"` + Namespaces []string `protobuf:"bytes,10,rep,name=namespaces,proto3" json:"namespaces,omitempty"` + Mindate *timestamp.Timestamp `protobuf:"bytes,11,opt,name=mindate,proto3" json:"mindate,omitempty"` + Maxdate *timestamp.Timestamp `protobuf:"bytes,12,opt,name=maxdate,proto3" json:"maxdate,omitempty"` } func (x *GetEventsRequest) Reset() { @@ -355,14 +355,14 @@ func (x *GetEventsRequest) GetNamespaces() []string { return nil } -func (x *GetEventsRequest) GetMindate() *timestamppb.Timestamp { +func (x *GetEventsRequest) GetMindate() *timestamp.Timestamp { if x != nil { return x.Mindate } return nil } -func (x *GetEventsRequest) GetMaxdate() *timestamppb.Timestamp { +func (x *GetEventsRequest) GetMaxdate() *timestamp.Timestamp { if x != nil { return x.Maxdate } @@ -421,9 +421,9 @@ type SubscribeEventRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Subscriber string `protobuf:"bytes,20,opt,name=subscriber,proto3" json:"subscriber,omitempty"` - Eventid string `protobuf:"bytes,21,opt,name=eventid,proto3" json:"eventid,omitempty"` - Data *structpb.Struct `protobuf:"bytes,22,opt,name=data,proto3" json:"data,omitempty"` + Subscriber string `protobuf:"bytes,20,opt,name=subscriber,proto3" json:"subscriber,omitempty"` + Eventid string `protobuf:"bytes,21,opt,name=eventid,proto3" json:"eventid,omitempty"` + Data *_struct.Struct `protobuf:"bytes,22,opt,name=data,proto3" json:"data,omitempty"` } func (x *SubscribeEventRequest) Reset() { @@ -472,7 +472,7 @@ func (x *SubscribeEventRequest) GetEventid() string { return "" } -func (x *SubscribeEventRequest) GetData() *structpb.Struct { +func (x *SubscribeEventRequest) GetData() *_struct.Struct { if x != nil { return x.Data } @@ -628,6 +628,100 @@ func (x *UnsubscribeEventResponse) GetOk() bool { return false } +type UpdateEventRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Event *Event `protobuf:"bytes,32,opt,name=event,proto3" json:"event,omitempty"` +} + +func (x *UpdateEventRequest) Reset() { + *x = UpdateEventRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_agenda_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateEventRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateEventRequest) ProtoMessage() {} + +func (x *UpdateEventRequest) ProtoReflect() protoreflect.Message { + mi := &file_agenda_proto_msgTypes[12] + 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 UpdateEventRequest.ProtoReflect.Descriptor instead. +func (*UpdateEventRequest) Descriptor() ([]byte, []int) { + return file_agenda_proto_rawDescGZIP(), []int{12} +} + +func (x *UpdateEventRequest) GetEvent() *Event { + if x != nil { + return x.Event + } + return nil +} + +type UpdateEventResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Event *Event `protobuf:"bytes,33,opt,name=event,proto3" json:"event,omitempty"` +} + +func (x *UpdateEventResponse) Reset() { + *x = UpdateEventResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_agenda_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateEventResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateEventResponse) ProtoMessage() {} + +func (x *UpdateEventResponse) ProtoReflect() protoreflect.Message { + mi := &file_agenda_proto_msgTypes[13] + 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 UpdateEventResponse.ProtoReflect.Descriptor instead. +func (*UpdateEventResponse) Descriptor() ([]byte, []int) { + return file_agenda_proto_rawDescGZIP(), []int{13} +} + +func (x *UpdateEventResponse) GetEvent() *Event { + if x != nil { + return x.Event + } + return nil +} + var File_agenda_proto protoreflect.FileDescriptor var file_agenda_proto_rawDesc = []byte{ @@ -685,34 +779,44 @@ var file_agenda_proto_rawDesc = []byte{ 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x22, 0x2a, 0x0a, 0x18, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x27, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0xf9, 0x02, 0x0a, 0x06, 0x41, 0x67, 0x65, 0x6e, - 0x64, 0x61, 0x12, 0x3a, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x12, 0x13, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, - 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x34, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x11, - 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x10, 0x55, 0x6e, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x55, - 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, - 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, - 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, - 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, - 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x32, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, + 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x13, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x21, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x32, 0xb5, 0x03, 0x0a, 0x06, 0x41, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x12, 0x3a, 0x0a, 0x0b, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x14, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x47, 0x65, + 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x47, 0x65, 0x74, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x3a, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, + 0x13, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0b, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x14, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x53, 0x75, 0x62, + 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, + 0x10, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x12, 0x18, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x55, 0x6e, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, + 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, + 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, + 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -727,7 +831,7 @@ func file_agenda_proto_rawDescGZIP() []byte { return file_agenda_proto_rawDescData } -var file_agenda_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_agenda_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_agenda_proto_goTypes = []interface{}{ (*CreateEventRequest)(nil), // 0: CreateEventRequest (*CreateEventResponse)(nil), // 1: CreateEventResponse @@ -741,35 +845,41 @@ var file_agenda_proto_goTypes = []interface{}{ (*SubscribeEventResponse)(nil), // 9: SubscribeEventResponse (*UnsubscribeEventRequest)(nil), // 10: UnsubscribeEventRequest (*UnsubscribeEventResponse)(nil), // 11: UnsubscribeEventResponse - (*Event)(nil), // 12: Event - (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp - (*structpb.Struct)(nil), // 14: google.protobuf.Struct + (*UpdateEventRequest)(nil), // 12: UpdateEventRequest + (*UpdateEventResponse)(nil), // 13: UpdateEventResponse + (*Event)(nil), // 14: Event + (*timestamp.Timestamp)(nil), // 15: google.protobuf.Timestamp + (*_struct.Struct)(nil), // 16: google.protobuf.Struct } var file_agenda_proto_depIdxs = []int32{ - 12, // 0: CreateEventRequest.event:type_name -> Event - 12, // 1: CreateEventResponse.event:type_name -> Event - 12, // 2: GetEventResponse.event:type_name -> Event - 13, // 3: GetEventsRequest.mindate:type_name -> google.protobuf.Timestamp - 13, // 4: GetEventsRequest.maxdate:type_name -> google.protobuf.Timestamp - 12, // 5: GetEventsResponse.events:type_name -> Event - 14, // 6: SubscribeEventRequest.data:type_name -> google.protobuf.Struct - 0, // 7: Agenda.CreateEvent:input_type -> CreateEventRequest - 2, // 8: Agenda.GetEvent:input_type -> GetEventRequest - 6, // 9: Agenda.GetEvents:input_type -> GetEventsRequest - 4, // 10: Agenda.DeleteEvent:input_type -> DeleteEventRequest - 8, // 11: Agenda.SubscribeEvent:input_type -> SubscribeEventRequest - 10, // 12: Agenda.UnsubscribeEvent:input_type -> UnsubscribeEventRequest - 1, // 13: Agenda.CreateEvent:output_type -> CreateEventResponse - 3, // 14: Agenda.GetEvent:output_type -> GetEventResponse - 7, // 15: Agenda.GetEvents:output_type -> GetEventsResponse - 5, // 16: Agenda.DeleteEvent:output_type -> DeleteEventResponse - 9, // 17: Agenda.SubscribeEvent:output_type -> SubscribeEventResponse - 11, // 18: Agenda.UnsubscribeEvent:output_type -> UnsubscribeEventResponse - 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 - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 14, // 0: CreateEventRequest.event:type_name -> Event + 14, // 1: CreateEventResponse.event:type_name -> Event + 14, // 2: GetEventResponse.event:type_name -> Event + 15, // 3: GetEventsRequest.mindate:type_name -> google.protobuf.Timestamp + 15, // 4: GetEventsRequest.maxdate:type_name -> google.protobuf.Timestamp + 14, // 5: GetEventsResponse.events:type_name -> Event + 16, // 6: SubscribeEventRequest.data:type_name -> google.protobuf.Struct + 14, // 7: UpdateEventRequest.event:type_name -> Event + 14, // 8: UpdateEventResponse.event:type_name -> Event + 0, // 9: Agenda.CreateEvent:input_type -> CreateEventRequest + 2, // 10: Agenda.GetEvent:input_type -> GetEventRequest + 6, // 11: Agenda.GetEvents:input_type -> GetEventsRequest + 4, // 12: Agenda.DeleteEvent:input_type -> DeleteEventRequest + 12, // 13: Agenda.UpdateEvent:input_type -> UpdateEventRequest + 8, // 14: Agenda.SubscribeEvent:input_type -> SubscribeEventRequest + 10, // 15: Agenda.UnsubscribeEvent:input_type -> UnsubscribeEventRequest + 1, // 16: Agenda.CreateEvent:output_type -> CreateEventResponse + 3, // 17: Agenda.GetEvent:output_type -> GetEventResponse + 7, // 18: Agenda.GetEvents:output_type -> GetEventsResponse + 5, // 19: Agenda.DeleteEvent:output_type -> DeleteEventResponse + 13, // 20: Agenda.UpdateEvent:output_type -> UpdateEventResponse + 9, // 21: Agenda.SubscribeEvent:output_type -> SubscribeEventResponse + 11, // 22: Agenda.UnsubscribeEvent:output_type -> UnsubscribeEventResponse + 16, // [16:23] is the sub-list for method output_type + 9, // [9:16] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_agenda_proto_init() } @@ -923,6 +1033,30 @@ func file_agenda_proto_init() { return nil } } + file_agenda_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateEventRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_agenda_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateEventResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -930,7 +1064,7 @@ func file_agenda_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_agenda_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/grpcapi/agenda.proto b/grpcapi/agenda.proto index 41368f3..397b4d7 100644 --- a/grpcapi/agenda.proto +++ b/grpcapi/agenda.proto @@ -13,7 +13,7 @@ service Agenda { rpc GetEvent(GetEventRequest) returns (GetEventResponse) {} rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {} rpc DeleteEvent(DeleteEventRequest) returns (DeleteEventResponse) {} - + rpc UpdateEvent(UpdateEventRequest) returns (UpdateEventResponse) {} rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {} rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {} } @@ -70,4 +70,12 @@ message UnsubscribeEventRequest { message UnsubscribeEventResponse { bool ok = 39; +} + +message UpdateEventRequest { + Event event = 32; +} + +message UpdateEventResponse { + Event event = 33; } \ No newline at end of file diff --git a/grpcapi/agenda_grpc.pb.go b/grpcapi/agenda_grpc.pb.go index 505f5df..70e5e34 100644 --- a/grpcapi/agenda_grpc.pb.go +++ b/grpcapi/agenda_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.19.4 +// - protoc v3.12.4 // source: agenda.proto package grpcapi @@ -26,6 +26,7 @@ type AgendaClient interface { GetEvent(ctx context.Context, in *GetEventRequest, opts ...grpc.CallOption) (*GetEventResponse, error) GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error) DeleteEvent(ctx context.Context, in *DeleteEventRequest, opts ...grpc.CallOption) (*DeleteEventResponse, error) + UpdateEvent(ctx context.Context, in *UpdateEventRequest, opts ...grpc.CallOption) (*UpdateEventResponse, error) SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error) UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error) } @@ -74,6 +75,15 @@ func (c *agendaClient) DeleteEvent(ctx context.Context, in *DeleteEventRequest, return out, nil } +func (c *agendaClient) UpdateEvent(ctx context.Context, in *UpdateEventRequest, opts ...grpc.CallOption) (*UpdateEventResponse, error) { + out := new(UpdateEventResponse) + err := c.cc.Invoke(ctx, "/Agenda/UpdateEvent", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *agendaClient) SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error) { out := new(SubscribeEventResponse) err := c.cc.Invoke(ctx, "/Agenda/SubscribeEvent", in, out, opts...) @@ -100,6 +110,7 @@ type AgendaServer interface { GetEvent(context.Context, *GetEventRequest) (*GetEventResponse, error) GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) + UpdateEvent(context.Context, *UpdateEventRequest) (*UpdateEventResponse, error) SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) mustEmbedUnimplementedAgendaServer() @@ -121,6 +132,9 @@ func (UnimplementedAgendaServer) GetEvents(context.Context, *GetEventsRequest) ( func (UnimplementedAgendaServer) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteEvent not implemented") } +func (UnimplementedAgendaServer) UpdateEvent(context.Context, *UpdateEventRequest) (*UpdateEventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateEvent not implemented") +} func (UnimplementedAgendaServer) SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubscribeEvent not implemented") } @@ -212,6 +226,24 @@ func _Agenda_DeleteEvent_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Agenda_UpdateEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateEventRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AgendaServer).UpdateEvent(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/Agenda/UpdateEvent", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AgendaServer).UpdateEvent(ctx, req.(*UpdateEventRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Agenda_SubscribeEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SubscribeEventRequest) if err := dec(in); err != nil { @@ -271,6 +303,10 @@ var Agenda_ServiceDesc = grpc.ServiceDesc{ MethodName: "DeleteEvent", Handler: _Agenda_DeleteEvent_Handler, }, + { + MethodName: "UpdateEvent", + Handler: _Agenda_UpdateEvent_Handler, + }, { MethodName: "SubscribeEvent", Handler: _Agenda_SubscribeEvent_Handler, diff --git a/grpcapi/events.go b/grpcapi/events.go index cd3961d..f5a7a6b 100644 --- a/grpcapi/events.go +++ b/grpcapi/events.go @@ -27,6 +27,7 @@ func (e Event) ToStorageType() storage.Event { MaxSubscribers: e.MaxSubscribers, Subscriptions: []storage.Subscription{}, Data: map[string]any{}, + Deleted: e.Deleted, } for _, v := range e.Subscriptions { @@ -94,6 +95,7 @@ func EventFromStorageType(event *storage.Event) (*Event, error) { MaxSubscribers: event.MaxSubscribers, Subscriptions: subscriptions, Data: data, + Deleted: event.Deleted, }, nil } diff --git a/grpcapi/events.pb.go b/grpcapi/events.pb.go index 01b03ff..c512874 100644 --- a/grpcapi/events.pb.go +++ b/grpcapi/events.pb.go @@ -1,16 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.19.4 +// protoc-gen-go v1.28.1 +// protoc v3.12.4 // source: events.proto package grpcapi import ( + _struct "github.com/golang/protobuf/ptypes/struct" + timestamp "github.com/golang/protobuf/ptypes/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - structpb "google.golang.org/protobuf/types/known/structpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -27,21 +27,22 @@ type Event struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` - Owners []string `protobuf:"bytes,4,rep,name=owners,proto3" json:"owners,omitempty"` - RestrictedTo []string `protobuf:"bytes,5,rep,name=restricted_to,json=restrictedTo,proto3" json:"restricted_to,omitempty"` - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` - Startdate *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"` - Enddate *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"` - Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"` - Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"` - Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"` - MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"` - Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"` - Data *structpb.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Owners []string `protobuf:"bytes,4,rep,name=owners,proto3" json:"owners,omitempty"` + RestrictedTo []string `protobuf:"bytes,5,rep,name=restricted_to,json=restrictedTo,proto3" json:"restricted_to,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` + Startdate *timestamp.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"` + Enddate *timestamp.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"` + Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"` + Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"` + Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"` + MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"` + Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"` + Data *_struct.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"` + Deleted bool `protobuf:"varint,16,opt,name=deleted,proto3" json:"deleted,omitempty"` } func (x *Event) Reset() { @@ -125,14 +126,14 @@ func (x *Event) GetDescription() string { return "" } -func (x *Event) GetStartdate() *timestamppb.Timestamp { +func (x *Event) GetStartdate() *timestamp.Timestamp { if x != nil { return x.Startdate } return nil } -func (x *Event) GetEnddate() *timestamppb.Timestamp { +func (x *Event) GetEnddate() *timestamp.Timestamp { if x != nil { return x.Enddate } @@ -174,23 +175,30 @@ func (x *Event) GetSubscriptions() []*Subscription { return nil } -func (x *Event) GetData() *structpb.Struct { +func (x *Event) GetData() *_struct.Struct { if x != nil { return x.Data } return nil } +func (x *Event) GetDeleted() bool { + if x != nil { + return x.Deleted + } + return false +} + type Subscription struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,20,opt,name=id,proto3" json:"id,omitempty"` - Subscriber string `protobuf:"bytes,21,opt,name=subscriber,proto3" json:"subscriber,omitempty"` - Tags []string `protobuf:"bytes,22,rep,name=tags,proto3" json:"tags,omitempty"` - Data *structpb.Struct `protobuf:"bytes,23,opt,name=data,proto3" json:"data,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,24,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Id string `protobuf:"bytes,20,opt,name=id,proto3" json:"id,omitempty"` + Subscriber string `protobuf:"bytes,21,opt,name=subscriber,proto3" json:"subscriber,omitempty"` + Tags []string `protobuf:"bytes,22,rep,name=tags,proto3" json:"tags,omitempty"` + Data *_struct.Struct `protobuf:"bytes,23,opt,name=data,proto3" json:"data,omitempty"` + CreatedAt *timestamp.Timestamp `protobuf:"bytes,24,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` } func (x *Subscription) Reset() { @@ -246,14 +254,14 @@ func (x *Subscription) GetTags() []string { return nil } -func (x *Subscription) GetData() *structpb.Struct { +func (x *Subscription) GetData() *_struct.Struct { if x != nil { return x.Data } return nil } -func (x *Subscription) GetCreatedAt() *timestamppb.Timestamp { +func (x *Subscription) GetCreatedAt() *timestamp.Timestamp { if x != nil { return x.CreatedAt } @@ -267,7 +275,7 @@ var file_events_proto_rawDesc = []byte{ 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x87, 0x04, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x04, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, @@ -300,22 +308,24 @@ var file_events_proto_rawDesc = []byte{ 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x14, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, - 0x18, 0x16, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, - 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x64, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, + 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, + 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x17, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, + 0x74, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x2e, + 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, + 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, + 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -332,10 +342,10 @@ func file_events_proto_rawDescGZIP() []byte { var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_events_proto_goTypes = []interface{}{ - (*Event)(nil), // 0: Event - (*Subscription)(nil), // 1: Subscription - (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp - (*structpb.Struct)(nil), // 3: google.protobuf.Struct + (*Event)(nil), // 0: Event + (*Subscription)(nil), // 1: Subscription + (*timestamp.Timestamp)(nil), // 2: google.protobuf.Timestamp + (*_struct.Struct)(nil), // 3: google.protobuf.Struct } var file_events_proto_depIdxs = []int32{ 2, // 0: Event.startdate:type_name -> google.protobuf.Timestamp diff --git a/grpcapi/events.proto b/grpcapi/events.proto index f90cd5f..979df85 100644 --- a/grpcapi/events.proto +++ b/grpcapi/events.proto @@ -21,6 +21,7 @@ message Event { int64 max_subscribers = 13; repeated Subscription subscriptions = 14; google.protobuf.Struct data = 15; + bool deleted = 16; } message Subscription { diff --git a/grpcapi/grpcapi.go b/grpcapi/grpcapi.go index 9f4f022..5af28c8 100644 --- a/grpcapi/grpcapi.go +++ b/grpcapi/grpcapi.go @@ -94,6 +94,24 @@ func (s AgendaServerImpl) SubscribeEvent(ctx context.Context, req *SubscribeEven func (s AgendaServerImpl) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented") } + +///////////////////////////////////////////////////////////////////////////////////////// +func (s AgendaServerImpl) UpdateEvent(ctx context.Context, req *UpdateEventRequest) (*UpdateEventResponse, error) { + b := req.Event.ToStorageType() + event, err := s.handler.UpdateEvent(b) + if err != nil { + fmt.Println(err) + return nil, status.Errorf(codes.AlreadyExists, "event update failed : %v", err) + } + response, err := EventFromStorageType(event) + if err != nil { + fmt.Println(err) + return nil, status.Errorf(codes.Internal, "issue while retrieving event : %v", err) + } + return &UpdateEventResponse{Event: response}, nil +} + +////////////////////////////////////////////////////////////////////////////////////////////// func (s AgendaServerImpl) mustEmbedUnimplementedAgendaServer() {} func Run(done chan error, cfg *viper.Viper, handler handlers.AgendaHandler) { diff --git a/handlers/events.go b/handlers/events.go index 09d958c..e8f4118 100644 --- a/handlers/events.go +++ b/handlers/events.go @@ -70,3 +70,24 @@ func (h AgendaHandler) SubscribeEvent(eventid string, subscriber string, data ma err = h.storage.AddSubscription(eventid, subscription) return } + +// func (h AgendaHandler) UnsubscribeEvent(eventid string, subscriber string) (err error) { +// if eventid == "" || subscriber == "" { +// return errors.New("missing eventid or subscriber") +// } +// event, err = h.storage.GetEvent(eventid) +// for i := 0; i < event.Subscriptions; i++ { + +// } +// return +// } + +func (h AgendaHandler) UpdateEvent(event storage.Event) (*storage.Event, error) { + + // Store the account + if err := h.storage.UpdateEvent(event); err != nil { + return nil, err + } + + return &event, nil +} diff --git a/storage/events.go b/storage/events.go index b2d2bdd..e71aeb0 100644 --- a/storage/events.go +++ b/storage/events.go @@ -18,6 +18,7 @@ type Event struct { MaxSubscribers int64 `json:"max_subscribers"` Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"` Data map[string]any `json:"data"` + Deleted bool `json:"deleted"` } type Subscription struct { diff --git a/storage/mongodb.go b/storage/mongodb.go index 49e4bc3..c90b65d 100644 --- a/storage/mongodb.go +++ b/storage/mongodb.go @@ -120,3 +120,13 @@ func (s MongoDBStorage) AddSubscription(eventid string, subscription Subscriptio _, err := collection.UpdateOne(context.TODO(), filter, push) return err } + +func (s MongoDBStorage) UpdateEvent(event Event) error { + collection := s.Client.Database(s.DbName).Collection(s.Collections["events"]) + if _, err := collection.ReplaceOne(context.TODO(), bson.M{"_id": event.ID}, event); err != nil { + fmt.Println(err) + return err + } + + return nil +} diff --git a/storage/storage.go b/storage/storage.go index 966aa1a..1d3a8b1 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -11,6 +11,7 @@ type Storage interface { GetEvent(string) (*Event, error) GetEvents(namespaces []string) ([]Event, error) AddSubscription(eventid string, subscription Subscription) error + UpdateEvent(Event) error } type StorageImpl struct { }