Initial commit

This commit is contained in:
2022-09-05 07:27:52 +02:00
commit 3699479c5e
19 changed files with 2730 additions and 0 deletions

7
grpcapi/README.md Normal file
View File

@@ -0,0 +1,7 @@
# COOPGO Agenda gRPC API
Generate Go code from proto files :
```
protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. ./*.proto
```

929
grpcapi/agenda.pb.go Normal file
View File

@@ -0,0 +1,929 @@
//COOPGO Agenda gRPC service definition
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: agenda.proto
package grpcapi
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CreateEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
}
func (x *CreateEventRequest) Reset() {
*x = CreateEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateEventRequest) ProtoMessage() {}
func (x *CreateEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 CreateEventRequest.ProtoReflect.Descriptor instead.
func (*CreateEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{0}
}
func (x *CreateEventRequest) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
type CreateEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"`
}
func (x *CreateEventResponse) Reset() {
*x = CreateEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateEventResponse) ProtoMessage() {}
func (x *CreateEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 CreateEventResponse.ProtoReflect.Descriptor instead.
func (*CreateEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{1}
}
func (x *CreateEventResponse) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
type GetEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *GetEventRequest) Reset() {
*x = GetEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEventRequest) ProtoMessage() {}
func (x *GetEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 GetEventRequest.ProtoReflect.Descriptor instead.
func (*GetEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{2}
}
func (x *GetEventRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,4,opt,name=event,proto3" json:"event,omitempty"`
}
func (x *GetEventResponse) Reset() {
*x = GetEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEventResponse) ProtoMessage() {}
func (x *GetEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 GetEventResponse.ProtoReflect.Descriptor instead.
func (*GetEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{3}
}
func (x *GetEventResponse) GetEvent() *Event {
if x != nil {
return x.Event
}
return nil
}
type DeleteEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,5,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *DeleteEventRequest) Reset() {
*x = DeleteEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteEventRequest) ProtoMessage() {}
func (x *DeleteEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 DeleteEventRequest.ProtoReflect.Descriptor instead.
func (*DeleteEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{4}
}
func (x *DeleteEventRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type DeleteEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,6,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *DeleteEventResponse) Reset() {
*x = DeleteEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteEventResponse) ProtoMessage() {}
func (x *DeleteEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 DeleteEventResponse.ProtoReflect.Descriptor instead.
func (*DeleteEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{5}
}
func (x *DeleteEventResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
type GetEventsRequest struct {
state protoimpl.MessageState
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"`
}
func (x *GetEventsRequest) Reset() {
*x = GetEventsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEventsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEventsRequest) ProtoMessage() {}
func (x *GetEventsRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_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 GetEventsRequest.ProtoReflect.Descriptor instead.
func (*GetEventsRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{6}
}
func (x *GetEventsRequest) GetNamespaces() []string {
if x != nil {
return x.Namespaces
}
return nil
}
func (x *GetEventsRequest) GetMindate() *timestamppb.Timestamp {
if x != nil {
return x.Mindate
}
return nil
}
func (x *GetEventsRequest) GetMaxdate() *timestamppb.Timestamp {
if x != nil {
return x.Maxdate
}
return nil
}
type GetEventsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Events []*Event `protobuf:"bytes,13,rep,name=events,proto3" json:"events,omitempty"`
}
func (x *GetEventsResponse) Reset() {
*x = GetEventsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetEventsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetEventsResponse) ProtoMessage() {}
func (x *GetEventsResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[7]
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 GetEventsResponse.ProtoReflect.Descriptor instead.
func (*GetEventsResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{7}
}
func (x *GetEventsResponse) GetEvents() []*Event {
if x != nil {
return x.Events
}
return nil
}
type SubscribeEventRequest struct {
state protoimpl.MessageState
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"`
}
func (x *SubscribeEventRequest) Reset() {
*x = SubscribeEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeEventRequest) ProtoMessage() {}
func (x *SubscribeEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[8]
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 SubscribeEventRequest.ProtoReflect.Descriptor instead.
func (*SubscribeEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{8}
}
func (x *SubscribeEventRequest) GetSubscriber() string {
if x != nil {
return x.Subscriber
}
return ""
}
func (x *SubscribeEventRequest) GetEventid() string {
if x != nil {
return x.Eventid
}
return ""
}
type SubscribeEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,22,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *SubscribeEventResponse) Reset() {
*x = SubscribeEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeEventResponse) ProtoMessage() {}
func (x *SubscribeEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[9]
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 SubscribeEventResponse.ProtoReflect.Descriptor instead.
func (*SubscribeEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{9}
}
func (x *SubscribeEventResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
type UnsubscribeEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Subscriber string `protobuf:"bytes,30,opt,name=subscriber,proto3" json:"subscriber,omitempty"`
Eventid string `protobuf:"bytes,31,opt,name=eventid,proto3" json:"eventid,omitempty"`
}
func (x *UnsubscribeEventRequest) Reset() {
*x = UnsubscribeEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnsubscribeEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnsubscribeEventRequest) ProtoMessage() {}
func (x *UnsubscribeEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[10]
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 UnsubscribeEventRequest.ProtoReflect.Descriptor instead.
func (*UnsubscribeEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{10}
}
func (x *UnsubscribeEventRequest) GetSubscriber() string {
if x != nil {
return x.Subscriber
}
return ""
}
func (x *UnsubscribeEventRequest) GetEventid() string {
if x != nil {
return x.Eventid
}
return ""
}
type UnsubscribeEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,32,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *UnsubscribeEventResponse) Reset() {
*x = UnsubscribeEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnsubscribeEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnsubscribeEventResponse) ProtoMessage() {}
func (x *UnsubscribeEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[11]
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 UnsubscribeEventResponse.ProtoReflect.Descriptor instead.
func (*UnsubscribeEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{11}
}
func (x *UnsubscribeEventResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
var File_agenda_proto protoreflect.FileDescriptor
var file_agenda_proto_rawDesc = []byte{
0x0a, 0x0c, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 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, 0x1a,
0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x32, 0x0a,
0x12, 0x43, 0x72, 0x65, 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, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e,
0x74, 0x22, 0x33, 0x0a, 0x13, 0x43, 0x72, 0x65, 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, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x21, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x30, 0x0a, 0x10, 0x47, 0x65, 0x74,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a,
0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x24, 0x0a, 0x12, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
0x64, 0x22, 0x25, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x06,
0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x9e, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a,
0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28,
0x09, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x34, 0x0a,
0x07, 0x6d, 0x69, 0x6e, 0x64, 0x61, 0x74, 0x65, 0x18, 0x0b, 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, 0x07, 0x6d, 0x69, 0x6e, 0x64,
0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x64, 0x61, 0x74, 0x65, 0x18, 0x0c,
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, 0x07, 0x6d, 0x61, 0x78, 0x64, 0x61, 0x74, 0x65, 0x22, 0x33, 0x0a, 0x11, 0x47, 0x65, 0x74,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e,
0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x06,
0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x51,
0x0a, 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x62, 0x65, 0x72, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62,
0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74,
0x69, 0x64, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69,
0x64, 0x22, 0x28, 0x0a, 0x16, 0x53, 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, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x53, 0x0a, 0x17, 0x55,
0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73,
0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69,
0x64, 0x18, 0x1f, 0x20, 0x01, 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, 0x20, 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,
}
var (
file_agenda_proto_rawDescOnce sync.Once
file_agenda_proto_rawDescData = file_agenda_proto_rawDesc
)
func file_agenda_proto_rawDescGZIP() []byte {
file_agenda_proto_rawDescOnce.Do(func() {
file_agenda_proto_rawDescData = protoimpl.X.CompressGZIP(file_agenda_proto_rawDescData)
})
return file_agenda_proto_rawDescData
}
var file_agenda_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_agenda_proto_goTypes = []interface{}{
(*CreateEventRequest)(nil), // 0: CreateEventRequest
(*CreateEventResponse)(nil), // 1: CreateEventResponse
(*GetEventRequest)(nil), // 2: GetEventRequest
(*GetEventResponse)(nil), // 3: GetEventResponse
(*DeleteEventRequest)(nil), // 4: DeleteEventRequest
(*DeleteEventResponse)(nil), // 5: DeleteEventResponse
(*GetEventsRequest)(nil), // 6: GetEventsRequest
(*GetEventsResponse)(nil), // 7: GetEventsResponse
(*SubscribeEventRequest)(nil), // 8: SubscribeEventRequest
(*SubscribeEventResponse)(nil), // 9: SubscribeEventResponse
(*UnsubscribeEventRequest)(nil), // 10: UnsubscribeEventRequest
(*UnsubscribeEventResponse)(nil), // 11: UnsubscribeEventResponse
(*Event)(nil), // 12: Event
(*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp
}
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
0, // 6: Agenda.CreateEvent:input_type -> CreateEventRequest
2, // 7: Agenda.GetEvent:input_type -> GetEventRequest
6, // 8: Agenda.GetEvents:input_type -> GetEventsRequest
4, // 9: Agenda.DeleteEvent:input_type -> DeleteEventRequest
8, // 10: Agenda.SubscribeEvent:input_type -> SubscribeEventRequest
10, // 11: Agenda.UnsubscribeEvent:input_type -> UnsubscribeEventRequest
1, // 12: Agenda.CreateEvent:output_type -> CreateEventResponse
3, // 13: Agenda.GetEvent:output_type -> GetEventResponse
7, // 14: Agenda.GetEvents:output_type -> GetEventsResponse
5, // 15: Agenda.DeleteEvent:output_type -> DeleteEventResponse
9, // 16: Agenda.SubscribeEvent:output_type -> SubscribeEventResponse
11, // 17: Agenda.UnsubscribeEvent:output_type -> UnsubscribeEventResponse
12, // [12:18] is the sub-list for method output_type
6, // [6:12] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_agenda_proto_init() }
func file_agenda_proto_init() {
if File_agenda_proto != nil {
return
}
file_events_proto_init()
if !protoimpl.UnsafeEnabled {
file_agenda_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEventsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetEventsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnsubscribeEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnsubscribeEventResponse); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_agenda_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_agenda_proto_goTypes,
DependencyIndexes: file_agenda_proto_depIdxs,
MessageInfos: file_agenda_proto_msgTypes,
}.Build()
File_agenda_proto = out.File
file_agenda_proto_rawDesc = nil
file_agenda_proto_goTypes = nil
file_agenda_proto_depIdxs = nil
}

71
grpcapi/agenda.proto Normal file
View File

@@ -0,0 +1,71 @@
//COOPGO Agenda gRPC service definition
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/agenda/grpcapi";
import "google/protobuf/timestamp.proto";
import "events.proto";
service Agenda {
rpc CreateEvent(CreateEventRequest) returns (CreateEventResponse) {}
rpc GetEvent(GetEventRequest) returns (GetEventResponse) {}
rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {}
rpc DeleteEvent(DeleteEventRequest) returns (DeleteEventResponse) {}
rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {}
rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {}
}
message CreateEventRequest {
Event event = 1;
}
message CreateEventResponse {
Event event = 2;
}
message GetEventRequest {
string id = 3;
}
message GetEventResponse {
Event event = 4;
}
message DeleteEventRequest {
string id = 5;
}
message DeleteEventResponse {
bool ok = 6;
}
message GetEventsRequest {
repeated string namespaces = 10;
google.protobuf.Timestamp mindate = 11;
google.protobuf.Timestamp maxdate = 12;
}
message GetEventsResponse {
repeated Event events = 13;
}
message SubscribeEventRequest {
string subscriber = 20;
string eventid = 21;
}
message SubscribeEventResponse {
bool ok = 22;
}
message UnsubscribeEventRequest {
string subscriber = 30;
string eventid = 31;
}
message UnsubscribeEventResponse {
bool ok = 32;
}

285
grpcapi/agenda_grpc.pb.go Normal file
View File

@@ -0,0 +1,285 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: agenda.proto
package grpcapi
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// AgendaClient is the client API for Agenda service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type AgendaClient interface {
CreateEvent(ctx context.Context, in *CreateEventRequest, opts ...grpc.CallOption) (*CreateEventResponse, error)
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)
SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error)
UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error)
}
type agendaClient struct {
cc grpc.ClientConnInterface
}
func NewAgendaClient(cc grpc.ClientConnInterface) AgendaClient {
return &agendaClient{cc}
}
func (c *agendaClient) CreateEvent(ctx context.Context, in *CreateEventRequest, opts ...grpc.CallOption) (*CreateEventResponse, error) {
out := new(CreateEventResponse)
err := c.cc.Invoke(ctx, "/Agenda/CreateEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *agendaClient) GetEvent(ctx context.Context, in *GetEventRequest, opts ...grpc.CallOption) (*GetEventResponse, error) {
out := new(GetEventResponse)
err := c.cc.Invoke(ctx, "/Agenda/GetEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *agendaClient) GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error) {
out := new(GetEventsResponse)
err := c.cc.Invoke(ctx, "/Agenda/GetEvents", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *agendaClient) DeleteEvent(ctx context.Context, in *DeleteEventRequest, opts ...grpc.CallOption) (*DeleteEventResponse, error) {
out := new(DeleteEventResponse)
err := c.cc.Invoke(ctx, "/Agenda/DeleteEvent", 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...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *agendaClient) UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error) {
out := new(UnsubscribeEventResponse)
err := c.cc.Invoke(ctx, "/Agenda/UnsubscribeEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AgendaServer is the server API for Agenda service.
// All implementations must embed UnimplementedAgendaServer
// for forward compatibility
type AgendaServer interface {
CreateEvent(context.Context, *CreateEventRequest) (*CreateEventResponse, error)
GetEvent(context.Context, *GetEventRequest) (*GetEventResponse, error)
GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error)
DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error)
SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error)
UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error)
mustEmbedUnimplementedAgendaServer()
}
// UnimplementedAgendaServer must be embedded to have forward compatible implementations.
type UnimplementedAgendaServer struct {
}
func (UnimplementedAgendaServer) CreateEvent(context.Context, *CreateEventRequest) (*CreateEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateEvent not implemented")
}
func (UnimplementedAgendaServer) GetEvent(context.Context, *GetEventRequest) (*GetEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetEvent not implemented")
}
func (UnimplementedAgendaServer) GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetEvents not implemented")
}
func (UnimplementedAgendaServer) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteEvent not implemented")
}
func (UnimplementedAgendaServer) SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SubscribeEvent not implemented")
}
func (UnimplementedAgendaServer) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnsubscribeEvent not implemented")
}
func (UnimplementedAgendaServer) mustEmbedUnimplementedAgendaServer() {}
// UnsafeAgendaServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AgendaServer will
// result in compilation errors.
type UnsafeAgendaServer interface {
mustEmbedUnimplementedAgendaServer()
}
func RegisterAgendaServer(s grpc.ServiceRegistrar, srv AgendaServer) {
s.RegisterService(&Agenda_ServiceDesc, srv)
}
func _Agenda_CreateEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).CreateEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/CreateEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).CreateEvent(ctx, req.(*CreateEventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Agenda_GetEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).GetEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/GetEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).GetEvent(ctx, req.(*GetEventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Agenda_GetEvents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetEventsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).GetEvents(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/GetEvents",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).GetEvents(ctx, req.(*GetEventsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Agenda_DeleteEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).DeleteEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/DeleteEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).DeleteEvent(ctx, req.(*DeleteEventRequest))
}
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 {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).SubscribeEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/SubscribeEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).SubscribeEvent(ctx, req.(*SubscribeEventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Agenda_UnsubscribeEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UnsubscribeEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).UnsubscribeEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/UnsubscribeEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).UnsubscribeEvent(ctx, req.(*UnsubscribeEventRequest))
}
return interceptor(ctx, in, info, handler)
}
// Agenda_ServiceDesc is the grpc.ServiceDesc for Agenda service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Agenda_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Agenda",
HandlerType: (*AgendaServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateEvent",
Handler: _Agenda_CreateEvent_Handler,
},
{
MethodName: "GetEvent",
Handler: _Agenda_GetEvent_Handler,
},
{
MethodName: "GetEvents",
Handler: _Agenda_GetEvents_Handler,
},
{
MethodName: "DeleteEvent",
Handler: _Agenda_DeleteEvent_Handler,
},
{
MethodName: "SubscribeEvent",
Handler: _Agenda_SubscribeEvent_Handler,
},
{
MethodName: "UnsubscribeEvent",
Handler: _Agenda_UnsubscribeEvent_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "agenda.proto",
}

89
grpcapi/events.go Normal file
View File

@@ -0,0 +1,89 @@
package grpcapi
import (
"encoding/json"
"fmt"
"git.coopgo.io/coopgo-platform/agenda/storage"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
func (e Event) ToStorageType() storage.Event {
event := storage.Event{
ID: e.Id,
Namespace: e.Namespace,
Owners: e.Owners,
RestrictedTo: e.RestrictedTo,
Type: e.Type,
Name: e.Name,
Description: e.Description,
Startdate: e.Startdate.AsTime(),
Enddate: e.Enddate.AsTime(),
Starttime: e.Starttime,
Endtime: e.Endtime,
Allday: e.Allday,
MaxSubscribers: e.MaxSubscribers,
Subscribers: e.Subscribers,
Data: map[string]any{},
}
for k, d := range e.Data.GetFields() {
jsondata, err := protojson.Marshal(d)
if err != nil {
fmt.Println(err)
break
}
var data any
json.Unmarshal(jsondata, &data)
event.Data[k] = data
}
return event
}
func EventFromStorageType(event *storage.Event) (*Event, error) {
d, err := sanitizeData(event.Data)
if err != nil {
return nil, err
}
data, err := structpb.NewStruct(d)
if err != nil {
fmt.Println(err)
return nil, err
}
return &Event{
Id: event.ID,
Namespace: event.Namespace,
Type: event.Type,
Owners: event.Owners,
RestrictedTo: event.RestrictedTo,
Name: event.Name,
Description: event.Description,
Startdate: timestamppb.New(event.Startdate),
Enddate: timestamppb.New(event.Enddate),
Starttime: event.Starttime,
Endtime: event.Endtime,
Allday: event.Allday,
MaxSubscribers: event.MaxSubscribers,
Subscribers: event.Subscribers,
Data: data,
}, nil
}
func sanitizeData(data map[string]any) (d map[string]any, err error) {
j, err := json.Marshal(data)
if err != nil {
return nil, err
}
if err = json.Unmarshal(j, &d); err != nil {
return nil, err
}
return d, nil
}

295
grpcapi/events.pb.go Normal file
View File

@@ -0,0 +1,295 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: events.proto
package grpcapi
import (
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"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Event struct {
state protoimpl.MessageState
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"`
Subscribers []string `protobuf:"bytes,14,rep,name=subscribers,proto3" json:"subscribers,omitempty"`
Data *structpb.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *Event) Reset() {
*x = Event{}
if protoimpl.UnsafeEnabled {
mi := &file_events_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Event) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Event) ProtoMessage() {}
func (x *Event) ProtoReflect() protoreflect.Message {
mi := &file_events_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 Event.ProtoReflect.Descriptor instead.
func (*Event) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{0}
}
func (x *Event) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Event) GetNamespace() string {
if x != nil {
return x.Namespace
}
return ""
}
func (x *Event) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *Event) GetOwners() []string {
if x != nil {
return x.Owners
}
return nil
}
func (x *Event) GetRestrictedTo() []string {
if x != nil {
return x.RestrictedTo
}
return nil
}
func (x *Event) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Event) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *Event) GetStartdate() *timestamppb.Timestamp {
if x != nil {
return x.Startdate
}
return nil
}
func (x *Event) GetEnddate() *timestamppb.Timestamp {
if x != nil {
return x.Enddate
}
return nil
}
func (x *Event) GetAllday() bool {
if x != nil {
return x.Allday
}
return false
}
func (x *Event) GetStarttime() string {
if x != nil {
return x.Starttime
}
return ""
}
func (x *Event) GetEndtime() string {
if x != nil {
return x.Endtime
}
return ""
}
func (x *Event) GetMaxSubscribers() int64 {
if x != nil {
return x.MaxSubscribers
}
return 0
}
func (x *Event) GetSubscribers() []string {
if x != nil {
return x.Subscribers
}
return nil
}
func (x *Event) GetData() *structpb.Struct {
if x != nil {
return x.Data
}
return nil
}
var File_events_proto protoreflect.FileDescriptor
var file_events_proto_rawDesc = []byte{
0x0a, 0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c,
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, 0xf4, 0x03,
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,
0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x77, 0x6e,
0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x77, 0x6e, 0x65, 0x72,
0x73, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x5f,
0x74, 0x6f, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69,
0x63, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65,
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x09,
0x73, 0x74, 0x61, 0x72, 0x74, 0x64, 0x61, 0x74, 0x65, 0x18, 0x08, 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, 0x73, 0x74, 0x61,
0x72, 0x74, 0x64, 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x65, 0x6e, 0x64, 0x64, 0x61, 0x74,
0x65, 0x18, 0x09, 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, 0x07, 0x65, 0x6e, 0x64, 0x64, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x61, 0x6c, 0x6c, 0x64, 0x61, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x6c,
0x6c, 0x64, 0x61, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x74, 0x69,
0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f,
0x6d, 0x61, 0x78, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x18,
0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x72, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x73,
0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 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, 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 (
file_events_proto_rawDescOnce sync.Once
file_events_proto_rawDescData = file_events_proto_rawDesc
)
func file_events_proto_rawDescGZIP() []byte {
file_events_proto_rawDescOnce.Do(func() {
file_events_proto_rawDescData = protoimpl.X.CompressGZIP(file_events_proto_rawDescData)
})
return file_events_proto_rawDescData
}
var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_events_proto_goTypes = []interface{}{
(*Event)(nil), // 0: Event
(*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp
(*structpb.Struct)(nil), // 2: google.protobuf.Struct
}
var file_events_proto_depIdxs = []int32{
1, // 0: Event.startdate:type_name -> google.protobuf.Timestamp
1, // 1: Event.enddate:type_name -> google.protobuf.Timestamp
2, // 2: Event.data:type_name -> google.protobuf.Struct
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_events_proto_init() }
func file_events_proto_init() {
if File_events_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_events_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Event); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_events_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_events_proto_goTypes,
DependencyIndexes: file_events_proto_depIdxs,
MessageInfos: file_events_proto_msgTypes,
}.Build()
File_events_proto = out.File
file_events_proto_rawDesc = nil
file_events_proto_goTypes = nil
file_events_proto_depIdxs = nil
}

24
grpcapi/events.proto Normal file
View File

@@ -0,0 +1,24 @@
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/agenda/grpcapi";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
message Event {
string id = 1;
string namespace = 2;
string type = 3;
repeated string owners = 4;
repeated string restricted_to = 5;
string name = 6;
string description = 7;
google.protobuf.Timestamp startdate = 8;
google.protobuf.Timestamp enddate = 9;
bool allday = 10;
string starttime = 11;
string endtime = 12;
int64 max_subscribers = 13;
repeated string subscribers = 14;
google.protobuf.Struct data = 15;
}

108
grpcapi/grpcapi.go Normal file
View File

@@ -0,0 +1,108 @@
package grpcapi
import (
context "context"
"fmt"
"log"
"net"
"git.coopgo.io/coopgo-platform/agenda/handlers"
"github.com/spf13/viper"
"google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
status "google.golang.org/grpc/status"
)
type AgendaServerImpl struct {
handler handlers.AgendaHandler
}
func NewAgendaServer(h handlers.AgendaHandler) *AgendaServerImpl {
return &AgendaServerImpl{
handler: h,
}
}
func (s AgendaServerImpl) CreateEvent(ctx context.Context, req *CreateEventRequest) (*CreateEventResponse, error) {
e := req.Event.ToStorageType()
event, err := s.handler.CreateEvent(e)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "event creation 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 &CreateEventResponse{Event: response}, nil
}
func (s AgendaServerImpl) GetEvent(ctx context.Context, req *GetEventRequest) (*GetEventResponse, error) {
event, err := s.handler.GetEvent(req.Id)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "issue while retrieving event : %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 &GetEventResponse{Event: response}, nil
}
func (s AgendaServerImpl) GetEvents(ctx context.Context, req *GetEventsRequest) (*GetEventsResponse, error) {
responses, err := s.handler.GetEvents(req.Namespaces)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.NotFound, "could not get events : %v", err)
}
var events []*Event
for _, e := range responses {
event, err := EventFromStorageType(&e)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "could not get events : %v", err)
}
events = append(events, event)
}
return &GetEventsResponse{Events: events}, nil
}
func (s AgendaServerImpl) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteEvent not implemented")
}
func (s AgendaServerImpl) SubscribeEvent(ctx context.Context, req *SubscribeEventRequest) (*SubscribeEventResponse, error) {
err := s.handler.SubscribeEvent(req.Eventid, req.Subscriber)
return &SubscribeEventResponse{
Ok: err != nil,
}, err
}
func (s AgendaServerImpl) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented")
}
func (s AgendaServerImpl) mustEmbedUnimplementedAgendaServer() {}
func Run(done chan error, cfg *viper.Viper, handler handlers.AgendaHandler) {
var (
dev_env = cfg.GetBool("dev_env")
address = ":" + cfg.GetString("services.grpc.port")
)
fmt.Println("-> GRPC server on", address)
server := grpc.NewServer()
RegisterAgendaServer(server, NewAgendaServer(handler))
l, err := net.Listen("tcp", address)
if err != nil {
log.Fatal(err)
}
if dev_env {
reflection.Register(server)
}
if err := server.Serve(l); err != nil {
fmt.Println("gRPC service ended")
done <- err
}
}