Compare commits
10 Commits
81b27976f9
...
postgresql
| Author | SHA1 | Date | |
|---|---|---|---|
| f06ed52547 | |||
| ef3add576f | |||
|
|
e55cf41e20 | ||
|
|
74fe5f57e3 | ||
|
|
72c292bd47 | ||
|
|
868e1321b7 | ||
|
|
bd480e875a | ||
|
|
3bf6876365 | ||
|
|
781ec59472 | ||
|
|
301f636072 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
config.yaml
|
config.yaml
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
__debug_bin
|
__debug_bin
|
||||||
@@ -3,7 +3,7 @@ FROM golang:alpine as builder
|
|||||||
ARG ACCESS_TOKEN_USR="nothing"
|
ARG ACCESS_TOKEN_USR="nothing"
|
||||||
ARG ACCESS_TOKEN_PWD="nothing"
|
ARG ACCESS_TOKEN_PWD="nothing"
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
RUN apk add --no-cache ca-certificates tzdata git
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|
||||||
|
|||||||
8
go.mod
8
go.mod
@@ -6,11 +6,14 @@ require (
|
|||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/spf13/viper v1.12.0
|
github.com/spf13/viper v1.12.0
|
||||||
go.mongodb.org/mongo-driver v1.10.1
|
go.mongodb.org/mongo-driver v1.10.1
|
||||||
google.golang.org/grpc v1.46.2
|
google.golang.org/grpc v1.48.0
|
||||||
google.golang.org/protobuf v1.28.0
|
google.golang.org/protobuf v1.28.1
|
||||||
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20221205162030-cecdcb20e1d5 // indirect
|
||||||
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20221205161801-9705c8d898f0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/golang/snappy v0.0.1 // indirect
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
@@ -38,7 +41,6 @@ require (
|
|||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
|
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
|
||||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -36,6 +36,10 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
|
|||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20221205162030-cecdcb20e1d5 h1:HL/M681G9R1ZN8XPp4LvG9hcF20//R9yQmr5cdXwQaM=
|
||||||
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20221205162030-cecdcb20e1d5/go.mod h1:s9OIFCNcjBAbBzRNHwoCTYV6kAntPG9CpT3GVweGdTY=
|
||||||
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20221205161801-9705c8d898f0 h1:CnLKO1kzoGtaqPhDqfOX3WPRFRcJVJZdGzPdBE4X//w=
|
||||||
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20221205161801-9705c8d898f0/go.mod h1:lozSy6qlIIYhvKKXscZzz28HAtS0qBDUTv5nofLRmYA=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
@@ -502,6 +506,8 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
|
|||||||
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||||
google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
|
google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
|
||||||
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||||
|
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
|
||||||
|
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@@ -517,6 +523,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
|||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
1558
grpcapi/agenda.pb.go
1558
grpcapi/agenda.pb.go
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ service Agenda {
|
|||||||
rpc GetEvent(GetEventRequest) returns (GetEventResponse) {}
|
rpc GetEvent(GetEventRequest) returns (GetEventResponse) {}
|
||||||
rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {}
|
rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {}
|
||||||
rpc DeleteEvent(DeleteEventRequest) returns (DeleteEventResponse) {}
|
rpc DeleteEvent(DeleteEventRequest) returns (DeleteEventResponse) {}
|
||||||
|
rpc UpdateEvent(UpdateEventRequest) returns (UpdateEventResponse) {}
|
||||||
rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {}
|
rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {}
|
||||||
rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {}
|
rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {}
|
||||||
rpc DeleteSubscription(DeleteSubscriptionRequest) returns (DeleteSubscriptionResponse) {}
|
rpc DeleteSubscription(DeleteSubscriptionRequest) returns (DeleteSubscriptionResponse) {}
|
||||||
@@ -82,3 +82,10 @@ message DeleteSubscriptionRequest {
|
|||||||
message DeleteSubscriptionResponse {
|
message DeleteSubscriptionResponse {
|
||||||
bool ok = 41;
|
bool ok = 41;
|
||||||
}
|
}
|
||||||
|
message UpdateEventRequest {
|
||||||
|
Event event = 52;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UpdateEventResponse {
|
||||||
|
Event event = 53;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.2.0
|
// - protoc-gen-go-grpc v1.2.0
|
||||||
// - protoc v3.21.12
|
// - protoc v3.12.4
|
||||||
// source: agenda.proto
|
// source: agenda.proto
|
||||||
|
|
||||||
package grpcapi
|
package grpcapi
|
||||||
@@ -26,6 +26,7 @@ type AgendaClient interface {
|
|||||||
GetEvent(ctx context.Context, in *GetEventRequest, opts ...grpc.CallOption) (*GetEventResponse, error)
|
GetEvent(ctx context.Context, in *GetEventRequest, opts ...grpc.CallOption) (*GetEventResponse, error)
|
||||||
GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error)
|
GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error)
|
||||||
DeleteEvent(ctx context.Context, in *DeleteEventRequest, opts ...grpc.CallOption) (*DeleteEventResponse, 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)
|
SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error)
|
||||||
UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error)
|
UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error)
|
||||||
DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*DeleteSubscriptionResponse, error)
|
DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*DeleteSubscriptionResponse, error)
|
||||||
@@ -75,6 +76,15 @@ func (c *agendaClient) DeleteEvent(ctx context.Context, in *DeleteEventRequest,
|
|||||||
return out, nil
|
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) {
|
func (c *agendaClient) SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error) {
|
||||||
out := new(SubscribeEventResponse)
|
out := new(SubscribeEventResponse)
|
||||||
err := c.cc.Invoke(ctx, "/Agenda/SubscribeEvent", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/Agenda/SubscribeEvent", in, out, opts...)
|
||||||
@@ -110,6 +120,7 @@ type AgendaServer interface {
|
|||||||
GetEvent(context.Context, *GetEventRequest) (*GetEventResponse, error)
|
GetEvent(context.Context, *GetEventRequest) (*GetEventResponse, error)
|
||||||
GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error)
|
GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error)
|
||||||
DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error)
|
DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error)
|
||||||
|
UpdateEvent(context.Context, *UpdateEventRequest) (*UpdateEventResponse, error)
|
||||||
SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error)
|
SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error)
|
||||||
UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error)
|
UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error)
|
||||||
DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*DeleteSubscriptionResponse, error)
|
DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*DeleteSubscriptionResponse, error)
|
||||||
@@ -132,6 +143,9 @@ func (UnimplementedAgendaServer) GetEvents(context.Context, *GetEventsRequest) (
|
|||||||
func (UnimplementedAgendaServer) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) {
|
func (UnimplementedAgendaServer) DeleteEvent(context.Context, *DeleteEventRequest) (*DeleteEventResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteEvent not implemented")
|
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) {
|
func (UnimplementedAgendaServer) SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method SubscribeEvent not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method SubscribeEvent not implemented")
|
||||||
}
|
}
|
||||||
@@ -226,6 +240,24 @@ func _Agenda_DeleteEvent_Handler(srv interface{}, ctx context.Context, dec func(
|
|||||||
return interceptor(ctx, in, info, handler)
|
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) {
|
func _Agenda_SubscribeEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(SubscribeEventRequest)
|
in := new(SubscribeEventRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@@ -303,6 +335,10 @@ var Agenda_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "DeleteEvent",
|
MethodName: "DeleteEvent",
|
||||||
Handler: _Agenda_DeleteEvent_Handler,
|
Handler: _Agenda_DeleteEvent_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UpdateEvent",
|
||||||
|
Handler: _Agenda_UpdateEvent_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "SubscribeEvent",
|
MethodName: "SubscribeEvent",
|
||||||
Handler: _Agenda_SubscribeEvent_Handler,
|
Handler: _Agenda_SubscribeEvent_Handler,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func (e Event) ToStorageType() storage.Event {
|
|||||||
Subscriptions: []storage.Subscription{},
|
Subscriptions: []storage.Subscription{},
|
||||||
DeletedSubscription: []storage.Subscription{},
|
DeletedSubscription: []storage.Subscription{},
|
||||||
Data: map[string]any{},
|
Data: map[string]any{},
|
||||||
|
Deleted: e.Deleted,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range e.Subscriptions {
|
for _, v := range e.Subscriptions {
|
||||||
@@ -106,6 +107,7 @@ func EventFromStorageType(event *storage.Event) (*Event, error) {
|
|||||||
Subscriptions: subscriptions,
|
Subscriptions: subscriptions,
|
||||||
DeletedSubscription: deletedsubscription,
|
DeletedSubscription: deletedsubscription,
|
||||||
Data: data,
|
Data: data,
|
||||||
|
Deleted: event.Deleted,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,295 +1,426 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.28.1
|
||||||
|
// protoc v3.12.4
|
||||||
// source: events.proto
|
// source: events.proto
|
||||||
|
|
||||||
package grpcapi
|
package grpcapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
_struct "github.com/golang/protobuf/ptypes/struct"
|
||||||
proto "github.com/golang/protobuf/proto"
|
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||||
structpb "google.golang.org/protobuf/types/known/structpb"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
math "math"
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
const (
|
||||||
var _ = proto.Marshal
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
var _ = fmt.Errorf
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
var _ = math.Inf
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
)
|
||||||
// is compatible with the proto package it is being compiled against.
|
|
||||||
// A compilation error at this line likely means your copy of the
|
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
state protoimpl.MessageState
|
||||||
Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
sizeCache protoimpl.SizeCache
|
||||||
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
|
unknownFields protoimpl.UnknownFields
|
||||||
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"`
|
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
|
Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||||
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"`
|
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
|
||||||
Startdate *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"`
|
Owners []string `protobuf:"bytes,4,rep,name=owners,proto3" json:"owners,omitempty"`
|
||||||
Enddate *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"`
|
RestrictedTo []string `protobuf:"bytes,5,rep,name=restricted_to,json=restrictedTo,proto3" json:"restricted_to,omitempty"`
|
||||||
Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"`
|
Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"`
|
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"`
|
||||||
Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"`
|
Startdate *timestamp.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"`
|
||||||
MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"`
|
Enddate *timestamp.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"`
|
||||||
Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
|
Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"`
|
||||||
DeletedSubscription []*Subscription `protobuf:"bytes,16,rep,name=deleted_subscription,json=deletedSubscription,proto3" json:"deleted_subscription,omitempty"`
|
Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"`
|
||||||
Data *structpb.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"`
|
Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
DeletedSubscription []*Subscription `protobuf:"bytes,16,rep,name=deleted_subscription,json=deletedSubscription,proto3" json:"deleted_subscription,omitempty"`
|
||||||
|
Data *_struct.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"`
|
||||||
|
Deleted bool `protobuf:"varint,17,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) Reset() { *m = Event{} }
|
func (x *Event) Reset() {
|
||||||
func (m *Event) String() string { return proto.CompactTextString(m) }
|
*x = Event{}
|
||||||
func (*Event) ProtoMessage() {}
|
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) {
|
func (*Event) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_8f22242cb04491f9, []int{0}
|
return file_events_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) XXX_Unmarshal(b []byte) error {
|
func (x *Event) GetId() string {
|
||||||
return xxx_messageInfo_Event.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Id
|
||||||
func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_Event.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *Event) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_Event.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *Event) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_Event.Size(m)
|
|
||||||
}
|
|
||||||
func (m *Event) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_Event.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_Event proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *Event) GetId() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Id
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetNamespace() string {
|
func (x *Event) GetNamespace() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Namespace
|
return x.Namespace
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetType() string {
|
func (x *Event) GetType() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Type
|
return x.Type
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetOwners() []string {
|
func (x *Event) GetOwners() []string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Owners
|
return x.Owners
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetRestrictedTo() []string {
|
func (x *Event) GetRestrictedTo() []string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.RestrictedTo
|
return x.RestrictedTo
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetName() string {
|
func (x *Event) GetName() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Name
|
return x.Name
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetDescription() string {
|
func (x *Event) GetDescription() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Description
|
return x.Description
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetStartdate() *timestamppb.Timestamp {
|
func (x *Event) GetStartdate() *timestamp.Timestamp {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Startdate
|
return x.Startdate
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetEnddate() *timestamppb.Timestamp {
|
func (x *Event) GetEnddate() *timestamp.Timestamp {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Enddate
|
return x.Enddate
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetAllday() bool {
|
func (x *Event) GetAllday() bool {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Allday
|
return x.Allday
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetStarttime() string {
|
func (x *Event) GetStarttime() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Starttime
|
return x.Starttime
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetEndtime() string {
|
func (x *Event) GetEndtime() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Endtime
|
return x.Endtime
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetMaxSubscribers() int64 {
|
func (x *Event) GetMaxSubscribers() int64 {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.MaxSubscribers
|
return x.MaxSubscribers
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetSubscriptions() []*Subscription {
|
func (x *Event) GetSubscriptions() []*Subscription {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Subscriptions
|
return x.Subscriptions
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetDeletedSubscription() []*Subscription {
|
func (x *Event) GetDeletedSubscription() []*Subscription {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.DeletedSubscription
|
return x.DeletedSubscription
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) GetData() *structpb.Struct {
|
func (x *Event) GetData() *_struct.Struct {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *Event) GetDeleted() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Deleted
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
Id string `protobuf:"bytes,20,opt,name=id,proto3" json:"id,omitempty"`
|
state protoimpl.MessageState
|
||||||
Subscriber string `protobuf:"bytes,21,opt,name=subscriber,proto3" json:"subscriber,omitempty"`
|
sizeCache protoimpl.SizeCache
|
||||||
Tags []string `protobuf:"bytes,22,rep,name=tags,proto3" json:"tags,omitempty"`
|
unknownFields protoimpl.UnknownFields
|
||||||
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"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
Subscriber string `protobuf:"bytes,21,opt,name=subscriber,proto3" json:"subscriber,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
Tags []string `protobuf:"bytes,22,rep,name=tags,proto3" json:"tags,omitempty"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
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 (m *Subscription) Reset() { *m = Subscription{} }
|
func (x *Subscription) Reset() {
|
||||||
func (m *Subscription) String() string { return proto.CompactTextString(m) }
|
*x = Subscription{}
|
||||||
func (*Subscription) ProtoMessage() {}
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_events_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Subscription) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Subscription) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Subscription) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_events_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 Subscription.ProtoReflect.Descriptor instead.
|
||||||
func (*Subscription) Descriptor() ([]byte, []int) {
|
func (*Subscription) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_8f22242cb04491f9, []int{1}
|
return file_events_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subscription) XXX_Unmarshal(b []byte) error {
|
func (x *Subscription) GetId() string {
|
||||||
return xxx_messageInfo_Subscription.Unmarshal(m, b)
|
if x != nil {
|
||||||
}
|
return x.Id
|
||||||
func (m *Subscription) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_Subscription.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (m *Subscription) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_Subscription.Merge(m, src)
|
|
||||||
}
|
|
||||||
func (m *Subscription) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_Subscription.Size(m)
|
|
||||||
}
|
|
||||||
func (m *Subscription) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_Subscription.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_Subscription proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *Subscription) GetId() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Id
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subscription) GetSubscriber() string {
|
func (x *Subscription) GetSubscriber() string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Subscriber
|
return x.Subscriber
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subscription) GetTags() []string {
|
func (x *Subscription) GetTags() []string {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Tags
|
return x.Tags
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subscription) GetData() *structpb.Struct {
|
func (x *Subscription) GetData() *_struct.Struct {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Subscription) GetCreatedAt() *timestamppb.Timestamp {
|
func (x *Subscription) GetCreatedAt() *timestamp.Timestamp {
|
||||||
if m != nil {
|
if x != nil {
|
||||||
return m.CreatedAt
|
return x.CreatedAt
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var File_events_proto protoreflect.FileDescriptor
|
||||||
proto.RegisterType((*Event)(nil), "Event")
|
|
||||||
proto.RegisterType((*Subscription)(nil), "Subscription")
|
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, 0xe3, 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,
|
||||||
|
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, 0x33, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
|
||||||
|
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53,
|
||||||
|
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x75, 0x62,
|
||||||
|
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x40, 0x0a, 0x14, 0x64, 0x65,
|
||||||
|
0x6c, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
|
||||||
|
0x6f, 0x6e, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63,
|
||||||
|
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64,
|
||||||
|
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 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, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c,
|
||||||
|
0x65, 0x74, 0x65, 0x64, 0x18, 0x11, 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var (
|
||||||
proto.RegisterFile("events.proto", fileDescriptor_8f22242cb04491f9)
|
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 fileDescriptor_8f22242cb04491f9 = []byte{
|
var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
// 458 bytes of a gzipped FileDescriptorProto
|
var file_events_proto_goTypes = []interface{}{
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4d, 0x6f, 0xd4, 0x30,
|
(*Event)(nil), // 0: Event
|
||||||
0x10, 0x55, 0x76, 0xb7, 0xdb, 0x66, 0xf6, 0xa3, 0xc8, 0x94, 0xd6, 0xaa, 0x2a, 0x88, 0xca, 0x81,
|
(*Subscription)(nil), // 1: Subscription
|
||||||
0x48, 0x40, 0x22, 0xb5, 0x1c, 0xe0, 0x06, 0x48, 0xfc, 0x81, 0x6c, 0x4f, 0x5c, 0x2a, 0x6f, 0xec,
|
(*timestamp.Timestamp)(nil), // 2: google.protobuf.Timestamp
|
||||||
0x46, 0x91, 0x92, 0xd8, 0xb2, 0x67, 0xa1, 0xfd, 0x6b, 0xfc, 0x03, 0xfe, 0x15, 0xf2, 0x24, 0xbb,
|
(*_struct.Struct)(nil), // 3: google.protobuf.Struct
|
||||||
0x49, 0x01, 0x69, 0x7b, 0x9b, 0x79, 0xef, 0xcd, 0xd8, 0xef, 0x69, 0x60, 0xae, 0x7e, 0xa8, 0x06,
|
}
|
||||||
0x5d, 0x62, 0xac, 0x46, 0x7d, 0x7e, 0x51, 0x68, 0x5d, 0x54, 0x2a, 0xa5, 0x6e, 0xbd, 0xb9, 0x4b,
|
var file_events_proto_depIdxs = []int32{
|
||||||
0x1d, 0xda, 0x4d, 0x8e, 0x1d, 0xfb, 0xea, 0x6f, 0x16, 0xcb, 0x5a, 0x39, 0x14, 0xb5, 0x69, 0x05,
|
2, // 0: Event.startdate:type_name -> google.protobuf.Timestamp
|
||||||
0x97, 0xbf, 0x27, 0x70, 0xf0, 0xcd, 0xef, 0x63, 0x4b, 0x18, 0x95, 0x92, 0x07, 0x51, 0x10, 0x87,
|
2, // 1: Event.enddate:type_name -> google.protobuf.Timestamp
|
||||||
0xd9, 0xa8, 0x94, 0xec, 0x02, 0xc2, 0x46, 0xd4, 0xca, 0x19, 0x91, 0x2b, 0x3e, 0x22, 0xb8, 0x07,
|
1, // 2: Event.subscriptions:type_name -> Subscription
|
||||||
0x18, 0x83, 0x09, 0x3e, 0x18, 0xc5, 0xc7, 0x44, 0x50, 0xcd, 0x4e, 0x61, 0xaa, 0x7f, 0x36, 0xca,
|
1, // 3: Event.deleted_subscription:type_name -> Subscription
|
||||||
0x3a, 0x3e, 0x89, 0xc6, 0x71, 0x98, 0x75, 0x1d, 0x7b, 0x0d, 0x0b, 0xab, 0x1c, 0xda, 0x32, 0x47,
|
3, // 4: Event.data:type_name -> google.protobuf.Struct
|
||||||
0x25, 0x6f, 0x51, 0xf3, 0x03, 0xa2, 0xe7, 0x3d, 0x78, 0xa3, 0xfd, 0x42, 0xbf, 0x9d, 0x4f, 0xdb,
|
3, // 5: Subscription.data:type_name -> google.protobuf.Struct
|
||||||
0x85, 0xbe, 0x66, 0x11, 0xcc, 0xa4, 0x72, 0xb9, 0x2d, 0x0d, 0x96, 0xba, 0xe1, 0x87, 0x44, 0x0d,
|
2, // 6: Subscription.created_at:type_name -> google.protobuf.Timestamp
|
||||||
0x21, 0xf6, 0x11, 0x42, 0x87, 0xc2, 0xa2, 0x14, 0xa8, 0xf8, 0x51, 0x14, 0xc4, 0xb3, 0xab, 0xf3,
|
7, // [7:7] is the sub-list for method output_type
|
||||||
0xa4, 0xf5, 0x9c, 0x6c, 0x3d, 0x27, 0x37, 0x5b, 0xcf, 0x59, 0x2f, 0x66, 0x1f, 0xe0, 0x50, 0x35,
|
7, // [7:7] is the sub-list for method input_type
|
||||||
0x92, 0xe6, 0xc2, 0xbd, 0x73, 0x5b, 0xa9, 0xb7, 0x28, 0xaa, 0x4a, 0x8a, 0x07, 0x0e, 0x51, 0x10,
|
7, // [7:7] is the sub-list for extension type_name
|
||||||
0x1f, 0x65, 0x5d, 0xe7, 0xc3, 0xa2, 0xd5, 0x3e, 0x5e, 0x3e, 0x6b, 0xc3, 0xda, 0x01, 0x8c, 0xd3,
|
7, // [7:7] is the sub-list for extension extendee
|
||||||
0x5b, 0xc4, 0xcd, 0x89, 0xdb, 0xb6, 0xec, 0x0d, 0x1c, 0xd7, 0xe2, 0xfe, 0xd6, 0x6d, 0xd6, 0xde,
|
0, // [0:7] is the sub-list for field type_name
|
||||||
0xd3, 0xda, 0x67, 0xb7, 0x88, 0x82, 0x78, 0x9c, 0x2d, 0x6b, 0x71, 0xbf, 0xea, 0x51, 0x76, 0x0d,
|
}
|
||||||
0x8b, 0x4e, 0x44, 0xc6, 0x1d, 0x5f, 0x46, 0xe3, 0x78, 0x76, 0xb5, 0x48, 0x56, 0x03, 0x34, 0x7b,
|
|
||||||
0xac, 0x61, 0x9f, 0xe1, 0x44, 0xaa, 0x4a, 0xf9, 0xd4, 0x87, 0x04, 0x7f, 0xf6, 0xbf, 0xd9, 0xe7,
|
func init() { file_events_proto_init() }
|
||||||
0x9d, 0x74, 0x08, 0xb2, 0xb7, 0x30, 0x91, 0x02, 0x05, 0x3f, 0xa6, 0x88, 0xce, 0xfe, 0x89, 0x68,
|
func file_events_proto_init() {
|
||||||
0x45, 0xc7, 0x96, 0x91, 0xe8, 0xf2, 0x57, 0x00, 0xf3, 0x47, 0xd3, 0xed, 0x49, 0x9d, 0xec, 0x4e,
|
if File_events_proto != nil {
|
||||||
0xea, 0x25, 0x40, 0xef, 0x94, 0xbf, 0x20, 0x7c, 0x80, 0xd0, 0x51, 0x89, 0xc2, 0xf1, 0x53, 0xba,
|
return
|
||||||
0x0f, 0xaa, 0x77, 0x3f, 0x38, 0x7b, 0xc2, 0x0f, 0xd8, 0x27, 0x80, 0xdc, 0x2a, 0xe1, 0x0d, 0x0b,
|
}
|
||||||
0xe4, 0x7c, 0xff, 0x3d, 0x74, 0xea, 0x2f, 0xf8, 0x35, 0xf9, 0xfe, 0xae, 0x28, 0x31, 0xc9, 0xb5,
|
if !protoimpl.UnsafeEnabled {
|
||||||
0x36, 0x85, 0x4e, 0x4a, 0x9d, 0xb6, 0xd5, 0x7b, 0x53, 0x09, 0xbc, 0xd3, 0xb6, 0x4e, 0x45, 0xa1,
|
file_events_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
0x1a, 0x29, 0xd2, 0xc2, 0x9a, 0x5c, 0x98, 0x72, 0x3d, 0xa5, 0x75, 0xd7, 0x7f, 0x02, 0x00, 0x00,
|
switch v := v.(*Event); i {
|
||||||
0xff, 0xff, 0x5f, 0xdb, 0xa6, 0x2e, 0x8e, 0x03, 0x00, 0x00,
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_events_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Subscription); 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: 2,
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ message Event {
|
|||||||
repeated Subscription subscriptions = 14;
|
repeated Subscription subscriptions = 14;
|
||||||
repeated Subscription deleted_subscription = 16;
|
repeated Subscription deleted_subscription = 16;
|
||||||
google.protobuf.Struct data = 15;
|
google.protobuf.Struct data = 15;
|
||||||
|
bool deleted = 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Subscription {
|
message Subscription {
|
||||||
|
|||||||
@@ -105,6 +105,23 @@ func (s AgendaServerImpl) DeleteSubscription(ctx context.Context, req *DeleteSub
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
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 (s AgendaServerImpl) mustEmbedUnimplementedAgendaServer() {}
|
||||||
|
|
||||||
func Run(done chan error, cfg *viper.Viper, handler handlers.AgendaHandler) {
|
func Run(done chan error, cfg *viper.Viper, handler handlers.AgendaHandler) {
|
||||||
|
|||||||
@@ -91,3 +91,12 @@ func (h AgendaHandler) DeleteSubscription(eventid string, subscriber string, dat
|
|||||||
err = h.storage.UpdateSubscription(eventid, subscriber, deletesubscription)
|
err = h.storage.UpdateSubscription(eventid, subscriber, deletesubscription)
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -18,6 +18,7 @@ func main() {
|
|||||||
var (
|
var (
|
||||||
service_name = cfg.GetString("name")
|
service_name = cfg.GetString("name")
|
||||||
grpc_enable = cfg.GetBool("services.grpc.enable")
|
grpc_enable = cfg.GetBool("services.grpc.enable")
|
||||||
|
dev_env = cfg.GetBool("dev_env")
|
||||||
)
|
)
|
||||||
|
|
||||||
storage, err := storage.NewStorage(cfg)
|
storage, err := storage.NewStorage(cfg)
|
||||||
@@ -28,6 +29,9 @@ func main() {
|
|||||||
handler := handlers.NewHandler(cfg, storage)
|
handler := handlers.NewHandler(cfg, storage)
|
||||||
|
|
||||||
fmt.Println("Running", service_name, ":")
|
fmt.Println("Running", service_name, ":")
|
||||||
|
if dev_env {
|
||||||
|
fmt.Printf("\033]0;%s\007", service_name)
|
||||||
|
}
|
||||||
|
|
||||||
failed := make(chan error)
|
failed := make(chan error)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Event struct {
|
|||||||
Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"`
|
Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"`
|
||||||
DeletedSubscription []Subscription `json:"deletedsubscriptions" bson:"deletedsubscriptions,omitempty"`
|
DeletedSubscription []Subscription `json:"deletedsubscriptions" bson:"deletedsubscriptions,omitempty"`
|
||||||
Data map[string]any `json:"data"`
|
Data map[string]any `json:"data"`
|
||||||
|
Deleted bool `json:"deleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
|
|||||||
@@ -143,3 +143,13 @@ func (s MongoDBStorage) UpdateSubscription(eventid string, subscriber string, de
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
513
storage/postgresql.go
Normal file
513
storage/postgresql.go
Normal file
@@ -0,0 +1,513 @@
|
|||||||
|
package storage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ariga.io/atlas/sql/postgres"
|
||||||
|
"ariga.io/atlas/sql/schema"
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"github.com/lib/pq"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostgresqlStorage struct {
|
||||||
|
DbConnection *sql.DB
|
||||||
|
Schema string
|
||||||
|
Tables map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error) {
|
||||||
|
var (
|
||||||
|
host = cfg.GetString("storage.db.psql.host")
|
||||||
|
port = cfg.GetString("storage.db.psql.port")
|
||||||
|
user = cfg.GetString("storage.db.psql.user")
|
||||||
|
password = cfg.GetString("storage.db.psql.password")
|
||||||
|
dbname = cfg.GetString("storage.db.psql.dbname")
|
||||||
|
sslmode = cfg.GetString("storage.db.psql.sslmode")
|
||||||
|
pg_schema = cfg.GetString("storage.db.psql.schema")
|
||||||
|
pgtables_event = cfg.GetString("storage.db.psql.tables.event")
|
||||||
|
pgtables_subscription = cfg.GetString("storage.db.psql.tables.subscription")
|
||||||
|
timezone = "Europe/Paris"
|
||||||
|
)
|
||||||
|
portInt, _ := strconv.Atoi(port)
|
||||||
|
psqlconn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s TimeZone=%s", host, portInt,
|
||||||
|
user, password, dbname, sslmode, timezone)
|
||||||
|
db, err := sql.Open("postgres", psqlconn)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("error", err)
|
||||||
|
return PostgresqlStorage{}, fmt.Errorf("connection to postgresql failed")
|
||||||
|
}
|
||||||
|
err = db.Ping()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return PostgresqlStorage{}, fmt.Errorf("connection to postgresql database failed")
|
||||||
|
}
|
||||||
|
return PostgresqlStorage{
|
||||||
|
DbConnection: db,
|
||||||
|
Schema: pg_schema,
|
||||||
|
Tables: map[string]string{
|
||||||
|
"event": fmt.Sprintf("%s.%s", pg_schema, pgtables_event),
|
||||||
|
"subscription": fmt.Sprintf("%s.%s", pg_schema, pgtables_subscription),
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) CreateEvent(e Event) error {
|
||||||
|
tx, err := psql.DbConnection.Begin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tx.Commit()
|
||||||
|
}()
|
||||||
|
dataEvent, err := json.Marshal(e.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
deletedSubscriptionsJSON, err := json.Marshal(e.DeletedSubscription)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
eventQuery := fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (id, namespace, owners, restricted_to, type, name, description, startdate,
|
||||||
|
enddate, starttime, endtime, allday, maxsubscribers, data, deleted, deletedsubscriptions)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
||||||
|
`, psql.Tables["event"])
|
||||||
|
|
||||||
|
ownersArray, err := pq.Array(e.Owners).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
restrictedToArray, err := pq.Array(e.RestrictedTo).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(
|
||||||
|
eventQuery,
|
||||||
|
e.ID,
|
||||||
|
e.Namespace,
|
||||||
|
ownersArray,
|
||||||
|
restrictedToArray,
|
||||||
|
e.Type,
|
||||||
|
e.Name,
|
||||||
|
e.Description,
|
||||||
|
e.Startdate,
|
||||||
|
e.Enddate,
|
||||||
|
e.Starttime,
|
||||||
|
e.Endtime,
|
||||||
|
e.Allday,
|
||||||
|
e.MaxSubscribers,
|
||||||
|
dataEvent,
|
||||||
|
e.Deleted,
|
||||||
|
deletedSubscriptionsJSON,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, subscription := range e.Subscriptions {
|
||||||
|
subscriptionQuery := fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (id, event_id, subscriber, tags, created_at, data)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
|
`, psql.Tables["subscription"])
|
||||||
|
dataSubscription, err := json.Marshal(subscription.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tagsArray, err := pq.Array(subscription.Tags).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(
|
||||||
|
subscriptionQuery,
|
||||||
|
subscription.ID,
|
||||||
|
e.ID,
|
||||||
|
subscription.Subscriber,
|
||||||
|
tagsArray,
|
||||||
|
subscription.CreatedAt,
|
||||||
|
dataSubscription,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) GetEvent(eventID string) (*Event, error) {
|
||||||
|
var event Event
|
||||||
|
eventQuery := fmt.Sprintf(`
|
||||||
|
SELECT id, namespace, owners, restricted_to, type, name, description, startdate,
|
||||||
|
enddate, starttime, endtime, allday, maxsubscribers, data, deleted, deletedsubscriptions
|
||||||
|
FROM %s
|
||||||
|
WHERE id = $1
|
||||||
|
`, psql.Tables["event"])
|
||||||
|
row := psql.DbConnection.QueryRow(eventQuery, eventID)
|
||||||
|
owners := pq.StringArray{}
|
||||||
|
restrictedTo := pq.StringArray{}
|
||||||
|
dataEvent := []byte{}
|
||||||
|
deletedSubscriptions := []byte{}
|
||||||
|
err := row.Scan(
|
||||||
|
&event.ID,
|
||||||
|
&event.Namespace,
|
||||||
|
&owners,
|
||||||
|
&restrictedTo,
|
||||||
|
&event.Type,
|
||||||
|
&event.Name,
|
||||||
|
&event.Description,
|
||||||
|
&event.Startdate,
|
||||||
|
&event.Enddate,
|
||||||
|
&event.Starttime,
|
||||||
|
&event.Endtime,
|
||||||
|
&event.Allday,
|
||||||
|
&event.MaxSubscribers,
|
||||||
|
&dataEvent,
|
||||||
|
&event.Deleted,
|
||||||
|
&deletedSubscriptions,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Owners = []string(owners)
|
||||||
|
event.RestrictedTo = []string(restrictedTo)
|
||||||
|
data := make(map[string]any)
|
||||||
|
err = json.Unmarshal(dataEvent, &data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Data = data
|
||||||
|
subscriptions, err := psql.getSubscriptions(eventID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Subscriptions = subscriptions
|
||||||
|
deletedSubs := []Subscription{}
|
||||||
|
err = json.Unmarshal(deletedSubscriptions, &deletedSubs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.DeletedSubscription = deletedSubs
|
||||||
|
return &event, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) GetEvents(namespaces []string) ([]Event, error) {
|
||||||
|
var events []Event
|
||||||
|
eventQuery := fmt.Sprintf(`
|
||||||
|
SELECT id, namespace, owners, restricted_to, type, name, description, startdate,
|
||||||
|
enddate, starttime, endtime, allday, maxsubscribers, data, deletedsubscriptions, deleted
|
||||||
|
FROM %s
|
||||||
|
WHERE namespace = ANY($1::text[])
|
||||||
|
`, psql.Tables["event"])
|
||||||
|
rows, err := psql.DbConnection.Query(eventQuery, pq.Array(namespaces))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var event Event
|
||||||
|
var owners pq.StringArray
|
||||||
|
var restrictedTo pq.StringArray
|
||||||
|
var dataEvent []byte
|
||||||
|
var deletedSubscriptions []byte
|
||||||
|
err := rows.Scan(
|
||||||
|
&event.ID,
|
||||||
|
&event.Namespace,
|
||||||
|
&owners,
|
||||||
|
&restrictedTo,
|
||||||
|
&event.Type,
|
||||||
|
&event.Name,
|
||||||
|
&event.Description,
|
||||||
|
&event.Startdate,
|
||||||
|
&event.Enddate,
|
||||||
|
&event.Starttime,
|
||||||
|
&event.Endtime,
|
||||||
|
&event.Allday,
|
||||||
|
&event.MaxSubscribers,
|
||||||
|
&dataEvent,
|
||||||
|
&deletedSubscriptions,
|
||||||
|
&event.Deleted,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Owners = []string(owners)
|
||||||
|
event.RestrictedTo = []string(restrictedTo)
|
||||||
|
err = json.Unmarshal(dataEvent, &event.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Subscriptions, err = psql.getSubscriptions(event.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(deletedSubscriptions, &event.DeletedSubscription)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
events = append(events, event)
|
||||||
|
}
|
||||||
|
return events, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) UpdateEvent(e Event) error {
|
||||||
|
tx, err := psql.DbConnection.Begin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tx.Commit()
|
||||||
|
}()
|
||||||
|
dataEvent, err := json.Marshal(e.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
deletedSubscriptions, err := json.Marshal(e.DeletedSubscription)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
eventQuery := fmt.Sprintf(`
|
||||||
|
UPDATE %s
|
||||||
|
SET namespace = $2,
|
||||||
|
owners = $3,
|
||||||
|
restricted_to = $4,
|
||||||
|
type = $5,
|
||||||
|
name = $6,
|
||||||
|
description = $7,
|
||||||
|
startdate = $8,
|
||||||
|
enddate = $9,
|
||||||
|
starttime = $10,
|
||||||
|
endtime = $11,
|
||||||
|
allday = $12,
|
||||||
|
maxsubscribers = $13,
|
||||||
|
data = $14,
|
||||||
|
deleted = $15,
|
||||||
|
deletedsubscriptions = $16
|
||||||
|
WHERE id = $1
|
||||||
|
`, psql.Tables["event"])
|
||||||
|
|
||||||
|
ownersArray, err := pq.Array(e.Owners).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
restrictedToArray, err := pq.Array(e.RestrictedTo).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(
|
||||||
|
eventQuery,
|
||||||
|
e.ID,
|
||||||
|
e.Namespace,
|
||||||
|
ownersArray,
|
||||||
|
restrictedToArray,
|
||||||
|
e.Type,
|
||||||
|
e.Name,
|
||||||
|
e.Description,
|
||||||
|
e.Startdate,
|
||||||
|
e.Enddate,
|
||||||
|
e.Starttime,
|
||||||
|
e.Endtime,
|
||||||
|
e.Allday,
|
||||||
|
e.MaxSubscribers,
|
||||||
|
dataEvent,
|
||||||
|
e.Deleted,
|
||||||
|
deletedSubscriptions,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, subscription := range e.Subscriptions {
|
||||||
|
subscriptionQuery := fmt.Sprintf(`
|
||||||
|
UPDATE %s
|
||||||
|
SET subscriber = $2,
|
||||||
|
tags = $3,
|
||||||
|
data = $4,
|
||||||
|
created_at= $5
|
||||||
|
WHERE event_id = $1
|
||||||
|
`, psql.Tables["subscription"])
|
||||||
|
|
||||||
|
dataSubscription, err := json.Marshal(subscription.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tagsArray, err := pq.Array(subscription.Tags).Value()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(
|
||||||
|
subscriptionQuery,
|
||||||
|
e.ID,
|
||||||
|
subscription.Subscriber,
|
||||||
|
tagsArray,
|
||||||
|
dataSubscription,
|
||||||
|
subscription.CreatedAt,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) AddSubscription(eventid string, subscription Subscription) error {
|
||||||
|
tags := pq.Array(subscription.Tags)
|
||||||
|
data, err := json.Marshal(subscription.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = psql.DbConnection.Exec(fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (id, event_id, subscriber, tags, created_at, data)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
|
`, psql.Tables["subscription"]),
|
||||||
|
subscription.ID,
|
||||||
|
eventid,
|
||||||
|
subscription.Subscriber,
|
||||||
|
tags,
|
||||||
|
subscription.CreatedAt,
|
||||||
|
data,
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error {
|
||||||
|
tx, err := psql.DbConnection.Begin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tx.Commit()
|
||||||
|
}()
|
||||||
|
|
||||||
|
subscriptionQuery := fmt.Sprintf(`
|
||||||
|
DELETE FROM %s
|
||||||
|
WHERE event_id = $1 AND subscriber = $2
|
||||||
|
`, psql.Tables["subscription"])
|
||||||
|
_, err = tx.Exec(
|
||||||
|
subscriptionQuery,
|
||||||
|
eventid,
|
||||||
|
subscriber,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
eventQuery := fmt.Sprintf(`
|
||||||
|
UPDATE %s
|
||||||
|
SET deletedsubscriptions = deletedsubscriptions || $1
|
||||||
|
WHERE id = $2
|
||||||
|
`, psql.Tables["event"])
|
||||||
|
deletedSubscriptions, err := json.Marshal(deletesubscription)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(
|
||||||
|
eventQuery,
|
||||||
|
deletedSubscriptions,
|
||||||
|
eventid,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) getSubscriptions(eventID string) ([]Subscription, error) {
|
||||||
|
var subscriptions []Subscription
|
||||||
|
subscriptionQuery := fmt.Sprintf(`
|
||||||
|
SELECT id, subscriber, tags, created_at, data
|
||||||
|
FROM %s
|
||||||
|
WHERE event_id = $1
|
||||||
|
`, psql.Tables["subscription"])
|
||||||
|
rows, err := psql.DbConnection.Query(subscriptionQuery, eventID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var subscription Subscription
|
||||||
|
var tags pq.StringArray
|
||||||
|
var dataSubscription []byte
|
||||||
|
err := rows.Scan(
|
||||||
|
&subscription.ID,
|
||||||
|
&subscription.Subscriber,
|
||||||
|
&tags,
|
||||||
|
&subscription.CreatedAt,
|
||||||
|
&dataSubscription,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subscription.Tags = []string(tags)
|
||||||
|
data := make(map[string]any)
|
||||||
|
err = json.Unmarshal(dataSubscription, &data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subscription.Data = data
|
||||||
|
subscriptions = append(subscriptions, subscription)
|
||||||
|
}
|
||||||
|
return subscriptions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (psql PostgresqlStorage) Migrate() error {
|
||||||
|
ctx := context.Background()
|
||||||
|
driver, err := postgres.Open(psql.DbConnection)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
existing, err := driver.InspectRealm(ctx, &schema.InspectRealmOption{Schemas: []string{psql.Schema}})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var desired schema.Realm
|
||||||
|
|
||||||
|
hcl, err := os.ReadFile("postgresql/schema.hcl")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = postgres.EvalHCLBytes(hcl, &desired, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
diff, err := driver.RealmDiff(existing, &desired)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = driver.ApplyChanges(ctx, diff)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
110
storage/postgresql/schema.hcl
Normal file
110
storage/postgresql/schema.hcl
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
table "event" {
|
||||||
|
schema = schema.agenda
|
||||||
|
column "id" {
|
||||||
|
null = false
|
||||||
|
type = uuid
|
||||||
|
}
|
||||||
|
column "namespace" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "owners" {
|
||||||
|
null = true
|
||||||
|
type = sql("text[]")
|
||||||
|
}
|
||||||
|
column "restricted_to" {
|
||||||
|
null = true
|
||||||
|
type = sql("text[]")
|
||||||
|
}
|
||||||
|
column "type" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "name" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "description" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "startdate" {
|
||||||
|
null = true
|
||||||
|
type = timestamptz
|
||||||
|
}
|
||||||
|
column "enddate" {
|
||||||
|
null = true
|
||||||
|
type = timestamptz
|
||||||
|
}
|
||||||
|
column "starttime" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "endtime" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "allday" {
|
||||||
|
null = true
|
||||||
|
type = boolean
|
||||||
|
}
|
||||||
|
column "maxsubscribers" {
|
||||||
|
null = true
|
||||||
|
type = bigint
|
||||||
|
}
|
||||||
|
column "data" {
|
||||||
|
null = true
|
||||||
|
type = jsonb
|
||||||
|
}
|
||||||
|
column "deleted" {
|
||||||
|
null = true
|
||||||
|
type = boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
column "deletedsubscriptions" {
|
||||||
|
null = true
|
||||||
|
type = jsonb
|
||||||
|
}
|
||||||
|
primary_key {
|
||||||
|
columns = [column.id]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table "subscription" {
|
||||||
|
schema = schema.agenda
|
||||||
|
column "id" {
|
||||||
|
null = false
|
||||||
|
type = uuid
|
||||||
|
}
|
||||||
|
column "event_id" {
|
||||||
|
null = true
|
||||||
|
type = uuid
|
||||||
|
}
|
||||||
|
column "subscriber" {
|
||||||
|
null = true
|
||||||
|
type = text
|
||||||
|
}
|
||||||
|
column "tags" {
|
||||||
|
null = true
|
||||||
|
type = sql("text[]")
|
||||||
|
}
|
||||||
|
column "created_at" {
|
||||||
|
null = true
|
||||||
|
type = timestamptz
|
||||||
|
}
|
||||||
|
column "data" {
|
||||||
|
null = true
|
||||||
|
type = jsonb
|
||||||
|
}
|
||||||
|
primary_key {
|
||||||
|
columns = [column.id]
|
||||||
|
}
|
||||||
|
foreign_key "subscription_event_id_fkey" {
|
||||||
|
columns = [column.event_id]
|
||||||
|
ref_columns = [table.event.column.id]
|
||||||
|
on_update = NO_ACTION
|
||||||
|
on_delete = NO_ACTION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
schema "agenda" {
|
||||||
|
}
|
||||||
277
storage/postgresql_test.go
Normal file
277
storage/postgresql_test.go
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
package storage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var cfg *viper.Viper
|
||||||
|
|
||||||
|
var date, _ = time.Parse(time.RFC3339Nano, "2023-05-04T16:00:50.165419+02:00")
|
||||||
|
var event = Event{
|
||||||
|
ID: uuid.New().String(),
|
||||||
|
Namespace: "test_namespace",
|
||||||
|
Owners: []string{"owners", "owners"},
|
||||||
|
RestrictedTo: []string{"restricted_to", "restricted_to"},
|
||||||
|
Type: "type",
|
||||||
|
Name: "test",
|
||||||
|
Description: "description",
|
||||||
|
Startdate: date,
|
||||||
|
Enddate: date,
|
||||||
|
Starttime: "starttime",
|
||||||
|
Endtime: "endtime",
|
||||||
|
Allday: false,
|
||||||
|
MaxSubscribers: 23,
|
||||||
|
Subscriptions: []Subscription{
|
||||||
|
{
|
||||||
|
ID: uuid.NewString(),
|
||||||
|
Subscriber: "subscriber1",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{
|
||||||
|
"test": "test",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DeletedSubscription: []Subscription{
|
||||||
|
{
|
||||||
|
ID: uuid.NewString(),
|
||||||
|
Subscriber: "subscriber_deleted",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{
|
||||||
|
"deleted": "deleted",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Data: map[string]any{
|
||||||
|
"data": "data",
|
||||||
|
},
|
||||||
|
Deleted: false,
|
||||||
|
}
|
||||||
|
var event1 = Event{
|
||||||
|
ID: uuid.New().String(),
|
||||||
|
Namespace: "test_namespace",
|
||||||
|
Owners: []string{"owners", "owners"},
|
||||||
|
RestrictedTo: []string{"restricted_to", "restricted_to"},
|
||||||
|
Type: "type",
|
||||||
|
Name: "test",
|
||||||
|
Description: "description",
|
||||||
|
Startdate: date,
|
||||||
|
Enddate: date,
|
||||||
|
Starttime: "starttime",
|
||||||
|
Endtime: "endtime",
|
||||||
|
Allday: false,
|
||||||
|
MaxSubscribers: 23,
|
||||||
|
Subscriptions: []Subscription{
|
||||||
|
{
|
||||||
|
ID: uuid.NewString(),
|
||||||
|
Subscriber: "subscriber1",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{
|
||||||
|
"test": "test",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DeletedSubscription: []Subscription{
|
||||||
|
{
|
||||||
|
ID: uuid.NewString(),
|
||||||
|
Subscriber: "subscriber_deleted",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{
|
||||||
|
"deleted": "deleted",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Data: map[string]any{
|
||||||
|
"data": "data",
|
||||||
|
},
|
||||||
|
Deleted: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cfg = viper.New()
|
||||||
|
cfg.SetDefault("storage.db.psql.host", "localhost")
|
||||||
|
cfg.SetDefault("storage.db.psql.port", "5432")
|
||||||
|
cfg.SetDefault("storage.db.psql.user", "postgres")
|
||||||
|
cfg.SetDefault("storage.db.psql.password", "postgres")
|
||||||
|
cfg.SetDefault("storage.db.psql.dbname", "coopgo_platform")
|
||||||
|
cfg.SetDefault("storage.db.psql.sslmode", "disable")
|
||||||
|
cfg.SetDefault("storage.db.psql.schema", "agenda")
|
||||||
|
cfg.SetDefault("storage.db.psql.tables.event", "event")
|
||||||
|
cfg.SetDefault("storage.db.psql.tables.subscription", "subscription")
|
||||||
|
cfg.SetConfigName("config") // Override default values in a config.yaml file within this directory
|
||||||
|
cfg.AddConfigPath(".")
|
||||||
|
cfg.ReadInConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresqlStorage_Initialize(t *testing.T) {
|
||||||
|
storage, err := NewPostgresqlStorage(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||||
|
}
|
||||||
|
defer storage.DbConnection.Close()
|
||||||
|
|
||||||
|
err = storage.Migrate()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("database migration issue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, err := storage.DbConnection.BeginTx(context.Background(), nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("transaction issue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer tx.Rollback()
|
||||||
|
_, err = tx.Exec(fmt.Sprintf("DELETE FROM %s;", storage.Tables["subscription"]))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("delete accounts subscription issue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = tx.Exec(fmt.Sprintf("DELETE FROM %s;", storage.Tables["event"]))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("delete accounts event issue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = tx.Commit(); err != nil {
|
||||||
|
t.Errorf("commit transaction issue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresqlStorage_CreateAndGetEvent(t *testing.T) {
|
||||||
|
storage, err := NewPostgresqlStorage(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||||
|
}
|
||||||
|
err = storage.CreateEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
retrieved_event, err := storage.GetEvent(event.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
diff := cmp.Diff(&event, retrieved_event)
|
||||||
|
if diff != "" {
|
||||||
|
fmt.Printf("The retrieved event differs from the original event:\n%s", diff)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresqlStorage_GetEvents(t *testing.T) {
|
||||||
|
storage, err := NewPostgresqlStorage(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||||
|
}
|
||||||
|
event.Namespace = "test"
|
||||||
|
err = storage.CreateEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
event1.Namespace = "test1"
|
||||||
|
err = storage.CreateEvent(event1)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
events, err := storage.GetEvents([]string{"test", "test1"})
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
diff := cmp.Diff(events, []Event{event, event1})
|
||||||
|
if diff != "" {
|
||||||
|
fmt.Printf("The retrieved event differs from the original event:\n%s", diff)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresqlStorage_AddSubscription(t *testing.T) {
|
||||||
|
storage, err := NewPostgresqlStorage(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||||
|
}
|
||||||
|
err = storage.CreateEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
subscription := Subscription{
|
||||||
|
ID: uuid.NewString(),
|
||||||
|
Subscriber: "salim",
|
||||||
|
Tags: []string{"tag"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{"data": "data"},
|
||||||
|
}
|
||||||
|
err = storage.AddSubscription(event.ID, subscription)
|
||||||
|
stored_event, err := storage.GetEvent(event.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
expected_event := Event{
|
||||||
|
ID: event.ID,
|
||||||
|
Namespace: event.Namespace,
|
||||||
|
Owners: event.Owners,
|
||||||
|
RestrictedTo: event.RestrictedTo,
|
||||||
|
Type: event.Type,
|
||||||
|
Name: event.Name,
|
||||||
|
Description: event.Description,
|
||||||
|
Startdate: event.Startdate,
|
||||||
|
Enddate: event.Enddate,
|
||||||
|
Starttime: event.Starttime,
|
||||||
|
Endtime: event.Endtime,
|
||||||
|
Allday: event.Allday,
|
||||||
|
MaxSubscribers: event.MaxSubscribers,
|
||||||
|
Subscriptions: []Subscription{event.Subscriptions[0], subscription},
|
||||||
|
DeletedSubscription: event.DeletedSubscription,
|
||||||
|
Data: event.Data,
|
||||||
|
Deleted: event.Deleted,
|
||||||
|
}
|
||||||
|
diff := cmp.Diff(stored_event, &expected_event)
|
||||||
|
if diff != "" {
|
||||||
|
fmt.Printf("The retrieved event differs from the original event:\n%s", diff)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPostgresqlStorage_UpdateEvent(t *testing.T) {
|
||||||
|
storage, err := NewPostgresqlStorage(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||||
|
}
|
||||||
|
err = storage.CreateEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
subscription := Subscription{
|
||||||
|
ID: event.Subscriptions[0].ID,
|
||||||
|
Subscriber: "updated",
|
||||||
|
Tags: []string{"tag"},
|
||||||
|
CreatedAt: date,
|
||||||
|
Data: map[string]any{"data": "data"},
|
||||||
|
}
|
||||||
|
event.Subscriptions[0] = subscription
|
||||||
|
|
||||||
|
err = storage.UpdateEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
retrieved_event, err := storage.GetEvent(event.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
diff := cmp.Diff(retrieved_event, &event)
|
||||||
|
if diff != "" {
|
||||||
|
fmt.Printf("The retrieved event differs from the original event:\n%s", diff)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ type Storage interface {
|
|||||||
GetEvents(namespaces []string) ([]Event, error)
|
GetEvents(namespaces []string) ([]Event, error)
|
||||||
AddSubscription(eventid string, subscription Subscription) error
|
AddSubscription(eventid string, subscription Subscription) error
|
||||||
UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error
|
UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error
|
||||||
|
UpdateEvent(Event) error
|
||||||
}
|
}
|
||||||
type StorageImpl struct {
|
type StorageImpl struct {
|
||||||
}
|
}
|
||||||
@@ -25,6 +26,9 @@ func NewStorage(cfg *viper.Viper) (Storage, error) {
|
|||||||
case "mongodb":
|
case "mongodb":
|
||||||
s, err := NewMongoDBStorage(cfg)
|
s, err := NewMongoDBStorage(cfg)
|
||||||
return s, err
|
return s, err
|
||||||
|
case "psql":
|
||||||
|
s, err := NewPostgresqlStorage(cfg)
|
||||||
|
return s, err
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user