Initial commit

This commit is contained in:
2022-08-11 17:21:32 +02:00
commit f6aa45944d
19 changed files with 2605 additions and 0 deletions

7
grpcapi/README.md Normal file
View File

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

66
grpcapi/groups.go Normal file
View File

@@ -0,0 +1,66 @@
package grpcapi
import (
"encoding/json"
"fmt"
"git.coopgo.io/coopgo-platform/groups-management/storage"
"google.golang.org/protobuf/encoding/protojson"
structpb "google.golang.org/protobuf/types/known/structpb"
)
func (g Group) ToStorageType() storage.Group {
group := storage.Group{
ID: g.Id,
Namespace: g.Namespace,
Members: g.Members,
Data: map[string]any{},
}
for k, d := range g.Data.GetFields() {
jsondata, err := protojson.Marshal(d)
if err != nil {
fmt.Println(err)
break
}
var data any
json.Unmarshal(jsondata, &data)
group.Data[k] = data
}
return group
}
func GroupFromStorageType(group *storage.Group) (*Group, error) {
d, err := sanitizeData(group.Data)
if err != nil {
return nil, err
}
data, err := structpb.NewStruct(d)
if err != nil {
fmt.Println(err)
return nil, err
}
return &Group{
Id: group.ID,
Namespace: group.Namespace,
Members: group.Members,
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
}

178
grpcapi/groups.pb.go Normal file
View File

@@ -0,0 +1,178 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: groups.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"
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 Group 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"`
Members []string `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"`
Data *structpb.Struct `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *Group) Reset() {
*x = Group{}
if protoimpl.UnsafeEnabled {
mi := &file_groups_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Group) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Group) ProtoMessage() {}
func (x *Group) ProtoReflect() protoreflect.Message {
mi := &file_groups_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 Group.ProtoReflect.Descriptor instead.
func (*Group) Descriptor() ([]byte, []int) {
return file_groups_proto_rawDescGZIP(), []int{0}
}
func (x *Group) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Group) GetNamespace() string {
if x != nil {
return x.Namespace
}
return ""
}
func (x *Group) GetMembers() []string {
if x != nil {
return x.Members
}
return nil
}
func (x *Group) GetData() *structpb.Struct {
if x != nil {
return x.Data
}
return nil
}
var File_groups_proto protoreflect.FileDescriptor
var file_groups_proto_rawDesc = []byte{
0x0a, 0x0c, 0x67, 0x72, 0x6f, 0x75, 0x70, 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, 0x22, 0x7c, 0x0a, 0x05,
0x47, 0x72, 0x6f, 0x75, 0x70, 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, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x03,
0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x2b, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 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, 0x39, 0x5a, 0x37, 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, 0x67, 0x72, 0x6f, 0x75,
0x70, 0x73, 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x67, 0x72,
0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_groups_proto_rawDescOnce sync.Once
file_groups_proto_rawDescData = file_groups_proto_rawDesc
)
func file_groups_proto_rawDescGZIP() []byte {
file_groups_proto_rawDescOnce.Do(func() {
file_groups_proto_rawDescData = protoimpl.X.CompressGZIP(file_groups_proto_rawDescData)
})
return file_groups_proto_rawDescData
}
var file_groups_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_groups_proto_goTypes = []interface{}{
(*Group)(nil), // 0: Group
(*structpb.Struct)(nil), // 1: google.protobuf.Struct
}
var file_groups_proto_depIdxs = []int32{
1, // 0: Group.data:type_name -> google.protobuf.Struct
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_groups_proto_init() }
func file_groups_proto_init() {
if File_groups_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_groups_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Group); 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_groups_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_groups_proto_goTypes,
DependencyIndexes: file_groups_proto_depIdxs,
MessageInfos: file_groups_proto_msgTypes,
}.Build()
File_groups_proto = out.File
file_groups_proto_rawDesc = nil
file_groups_proto_goTypes = nil
file_groups_proto_depIdxs = nil
}

12
grpcapi/groups.proto Normal file
View File

@@ -0,0 +1,12 @@
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/groups-management/grpcapi";
import "google/protobuf/struct.proto";
message Group {
string id = 1;
string namespace = 2;
repeated string members = 3;
google.protobuf.Struct data = 4;
}

View File

@@ -0,0 +1,912 @@
//COOPGO Groups Management gRPC service definition
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: groupsmanagement.proto
package grpcapi
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
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 AddGroupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Group *Group `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"`
}
func (x *AddGroupRequest) Reset() {
*x = AddGroupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddGroupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddGroupRequest) ProtoMessage() {}
func (x *AddGroupRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 AddGroupRequest.ProtoReflect.Descriptor instead.
func (*AddGroupRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{0}
}
func (x *AddGroupRequest) GetGroup() *Group {
if x != nil {
return x.Group
}
return nil
}
type AddGroupResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Group *Group `protobuf:"bytes,2,opt,name=group,proto3" json:"group,omitempty"`
}
func (x *AddGroupResponse) Reset() {
*x = AddGroupResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddGroupResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddGroupResponse) ProtoMessage() {}
func (x *AddGroupResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 AddGroupResponse.ProtoReflect.Descriptor instead.
func (*AddGroupResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{1}
}
func (x *AddGroupResponse) GetGroup() *Group {
if x != nil {
return x.Group
}
return nil
}
type GetGroupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"`
}
func (x *GetGroupRequest) Reset() {
*x = GetGroupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupRequest) ProtoMessage() {}
func (x *GetGroupRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupRequest.ProtoReflect.Descriptor instead.
func (*GetGroupRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{2}
}
func (x *GetGroupRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *GetGroupRequest) GetNamespace() string {
if x != nil {
return x.Namespace
}
return ""
}
type GetGroupResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Group *Group `protobuf:"bytes,5,opt,name=group,proto3" json:"group,omitempty"`
}
func (x *GetGroupResponse) Reset() {
*x = GetGroupResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupResponse) ProtoMessage() {}
func (x *GetGroupResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupResponse.ProtoReflect.Descriptor instead.
func (*GetGroupResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{3}
}
func (x *GetGroupResponse) GetGroup() *Group {
if x != nil {
return x.Group
}
return nil
}
type GetGroupsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Namespaces []string `protobuf:"bytes,6,rep,name=namespaces,proto3" json:"namespaces,omitempty"`
}
func (x *GetGroupsRequest) Reset() {
*x = GetGroupsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupsRequest) ProtoMessage() {}
func (x *GetGroupsRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupsRequest.ProtoReflect.Descriptor instead.
func (*GetGroupsRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{4}
}
func (x *GetGroupsRequest) GetNamespaces() []string {
if x != nil {
return x.Namespaces
}
return nil
}
type GetGroupsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Groups []*Group `protobuf:"bytes,7,rep,name=groups,proto3" json:"groups,omitempty"`
}
func (x *GetGroupsResponse) Reset() {
*x = GetGroupsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupsResponse) ProtoMessage() {}
func (x *GetGroupsResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupsResponse.ProtoReflect.Descriptor instead.
func (*GetGroupsResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{5}
}
func (x *GetGroupsResponse) GetGroups() []*Group {
if x != nil {
return x.Groups
}
return nil
}
type GetGroupsBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Groupids []string `protobuf:"bytes,6,rep,name=groupids,proto3" json:"groupids,omitempty"`
}
func (x *GetGroupsBatchRequest) Reset() {
*x = GetGroupsBatchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupsBatchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupsBatchRequest) ProtoMessage() {}
func (x *GetGroupsBatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupsBatchRequest.ProtoReflect.Descriptor instead.
func (*GetGroupsBatchRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{6}
}
func (x *GetGroupsBatchRequest) GetGroupids() []string {
if x != nil {
return x.Groupids
}
return nil
}
type GetGroupsBatchResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Groups []*Group `protobuf:"bytes,7,rep,name=groups,proto3" json:"groups,omitempty"`
}
func (x *GetGroupsBatchResponse) Reset() {
*x = GetGroupsBatchResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGroupsBatchResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGroupsBatchResponse) ProtoMessage() {}
func (x *GetGroupsBatchResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 GetGroupsBatchResponse.ProtoReflect.Descriptor instead.
func (*GetGroupsBatchResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{7}
}
func (x *GetGroupsBatchResponse) GetGroups() []*Group {
if x != nil {
return x.Groups
}
return nil
}
type SubscribeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Groupid string `protobuf:"bytes,8,opt,name=groupid,proto3" json:"groupid,omitempty"`
Memberid string `protobuf:"bytes,9,opt,name=memberid,proto3" json:"memberid,omitempty"`
}
func (x *SubscribeRequest) Reset() {
*x = SubscribeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeRequest) ProtoMessage() {}
func (x *SubscribeRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 SubscribeRequest.ProtoReflect.Descriptor instead.
func (*SubscribeRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{8}
}
func (x *SubscribeRequest) GetGroupid() string {
if x != nil {
return x.Groupid
}
return ""
}
func (x *SubscribeRequest) GetMemberid() string {
if x != nil {
return x.Memberid
}
return ""
}
type SubscribeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,10,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *SubscribeResponse) Reset() {
*x = SubscribeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SubscribeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubscribeResponse) ProtoMessage() {}
func (x *SubscribeResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 SubscribeResponse.ProtoReflect.Descriptor instead.
func (*SubscribeResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{9}
}
func (x *SubscribeResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
type UnsubscribeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Groupid string `protobuf:"bytes,8,opt,name=groupid,proto3" json:"groupid,omitempty"`
Memberid string `protobuf:"bytes,9,opt,name=memberid,proto3" json:"memberid,omitempty"`
}
func (x *UnsubscribeRequest) Reset() {
*x = UnsubscribeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnsubscribeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnsubscribeRequest) ProtoMessage() {}
func (x *UnsubscribeRequest) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 UnsubscribeRequest.ProtoReflect.Descriptor instead.
func (*UnsubscribeRequest) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{10}
}
func (x *UnsubscribeRequest) GetGroupid() string {
if x != nil {
return x.Groupid
}
return ""
}
func (x *UnsubscribeRequest) GetMemberid() string {
if x != nil {
return x.Memberid
}
return ""
}
type UnsubscribeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,10,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *UnsubscribeResponse) Reset() {
*x = UnsubscribeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_groupsmanagement_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnsubscribeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnsubscribeResponse) ProtoMessage() {}
func (x *UnsubscribeResponse) ProtoReflect() protoreflect.Message {
mi := &file_groupsmanagement_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 UnsubscribeResponse.ProtoReflect.Descriptor instead.
func (*UnsubscribeResponse) Descriptor() ([]byte, []int) {
return file_groupsmanagement_proto_rawDescGZIP(), []int{11}
}
func (x *UnsubscribeResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
var File_groupsmanagement_proto protoreflect.FileDescriptor
var file_groupsmanagement_proto_rawDesc = []byte{
0x0a, 0x16, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65,
0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2f, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x47, 0x72, 0x6f,
0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x05, 0x67, 0x72, 0x6f,
0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70,
0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x30, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x47, 0x72,
0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x67,
0x72, 0x6f, 0x75, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x72, 0x6f,
0x75, 0x70, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x3f, 0x0a, 0x0f, 0x47, 0x65, 0x74,
0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09,
0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x30, 0x0a, 0x10, 0x47, 0x65,
0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c,
0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e,
0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x32, 0x0a, 0x10,
0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x06,
0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73,
0x22, 0x33, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18,
0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x06, 0x67,
0x72, 0x6f, 0x75, 0x70, 0x73, 0x22, 0x33, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75,
0x70, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09,
0x52, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x64, 0x73, 0x22, 0x38, 0x0a, 0x16, 0x47, 0x65,
0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x07,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x06, 0x67, 0x72,
0x6f, 0x75, 0x70, 0x73, 0x22, 0x48, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75,
0x70, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x69, 0x64, 0x18, 0x09,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x69, 0x64, 0x22, 0x23,
0x0a, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52,
0x02, 0x6f, 0x6b, 0x22, 0x4a, 0x0a, 0x12, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f,
0x75, 0x70, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75,
0x70, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x69, 0x64, 0x18,
0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x69, 0x64, 0x22,
0x25, 0x0a, 0x13, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x0a, 0x20, 0x01,
0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0xe5, 0x02, 0x0a, 0x10, 0x47, 0x72, 0x6f, 0x75, 0x70,
0x73, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x31, 0x0a, 0x08, 0x41,
0x64, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x10, 0x2e, 0x41, 0x64, 0x64, 0x47, 0x72, 0x6f,
0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x41, 0x64, 0x64, 0x47,
0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31,
0x0a, 0x08, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74,
0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47,
0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x34, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x11,
0x2e, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x47, 0x72,
0x6f, 0x75, 0x70, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, 0x47,
0x72, 0x6f, 0x75, 0x70, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x42, 0x61, 0x74,
0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09,
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x11, 0x2e, 0x53, 0x75, 0x62, 0x73,
0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x53,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0b, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
0x65, 0x12, 0x13, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x39,
0x5a, 0x37, 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,
0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
file_groupsmanagement_proto_rawDescOnce sync.Once
file_groupsmanagement_proto_rawDescData = file_groupsmanagement_proto_rawDesc
)
func file_groupsmanagement_proto_rawDescGZIP() []byte {
file_groupsmanagement_proto_rawDescOnce.Do(func() {
file_groupsmanagement_proto_rawDescData = protoimpl.X.CompressGZIP(file_groupsmanagement_proto_rawDescData)
})
return file_groupsmanagement_proto_rawDescData
}
var file_groupsmanagement_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_groupsmanagement_proto_goTypes = []interface{}{
(*AddGroupRequest)(nil), // 0: AddGroupRequest
(*AddGroupResponse)(nil), // 1: AddGroupResponse
(*GetGroupRequest)(nil), // 2: GetGroupRequest
(*GetGroupResponse)(nil), // 3: GetGroupResponse
(*GetGroupsRequest)(nil), // 4: GetGroupsRequest
(*GetGroupsResponse)(nil), // 5: GetGroupsResponse
(*GetGroupsBatchRequest)(nil), // 6: GetGroupsBatchRequest
(*GetGroupsBatchResponse)(nil), // 7: GetGroupsBatchResponse
(*SubscribeRequest)(nil), // 8: SubscribeRequest
(*SubscribeResponse)(nil), // 9: SubscribeResponse
(*UnsubscribeRequest)(nil), // 10: UnsubscribeRequest
(*UnsubscribeResponse)(nil), // 11: UnsubscribeResponse
(*Group)(nil), // 12: Group
}
var file_groupsmanagement_proto_depIdxs = []int32{
12, // 0: AddGroupRequest.group:type_name -> Group
12, // 1: AddGroupResponse.group:type_name -> Group
12, // 2: GetGroupResponse.group:type_name -> Group
12, // 3: GetGroupsResponse.groups:type_name -> Group
12, // 4: GetGroupsBatchResponse.groups:type_name -> Group
0, // 5: GroupsManagement.AddGroup:input_type -> AddGroupRequest
2, // 6: GroupsManagement.GetGroup:input_type -> GetGroupRequest
4, // 7: GroupsManagement.GetGroups:input_type -> GetGroupsRequest
6, // 8: GroupsManagement.GetGroupsBatch:input_type -> GetGroupsBatchRequest
8, // 9: GroupsManagement.Subscribe:input_type -> SubscribeRequest
10, // 10: GroupsManagement.Unsubscribe:input_type -> UnsubscribeRequest
1, // 11: GroupsManagement.AddGroup:output_type -> AddGroupResponse
3, // 12: GroupsManagement.GetGroup:output_type -> GetGroupResponse
5, // 13: GroupsManagement.GetGroups:output_type -> GetGroupsResponse
7, // 14: GroupsManagement.GetGroupsBatch:output_type -> GetGroupsBatchResponse
9, // 15: GroupsManagement.Subscribe:output_type -> SubscribeResponse
11, // 16: GroupsManagement.Unsubscribe:output_type -> UnsubscribeResponse
11, // [11:17] is the sub-list for method output_type
5, // [5:11] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_groupsmanagement_proto_init() }
func file_groupsmanagement_proto_init() {
if File_groupsmanagement_proto != nil {
return
}
file_groups_proto_init()
if !protoimpl.UnsafeEnabled {
file_groupsmanagement_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddGroupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddGroupResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupsBatchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetGroupsBatchResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubscribeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnsubscribeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_groupsmanagement_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnsubscribeResponse); 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_groupsmanagement_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_groupsmanagement_proto_goTypes,
DependencyIndexes: file_groupsmanagement_proto_depIdxs,
MessageInfos: file_groupsmanagement_proto_msgTypes,
}.Build()
File_groupsmanagement_proto = out.File
file_groupsmanagement_proto_rawDesc = nil
file_groupsmanagement_proto_goTypes = nil
file_groupsmanagement_proto_depIdxs = nil
}

View File

@@ -0,0 +1,67 @@
//COOPGO Groups Management gRPC service definition
syntax = "proto3";
option go_package = "git.coopgo.io/coopgo-platform/groups-management/grpcapi";
import "groups.proto";
service GroupsManagement {
rpc AddGroup(AddGroupRequest) returns (AddGroupResponse) {}
rpc GetGroup(GetGroupRequest) returns (GetGroupResponse) {}
rpc GetGroups(GetGroupsRequest) returns (GetGroupsResponse) {}
rpc GetGroupsBatch(GetGroupsBatchRequest) returns (GetGroupsBatchResponse) {}
rpc Subscribe(SubscribeRequest) returns (SubscribeResponse) {}
rpc Unsubscribe(UnsubscribeRequest) returns (UnsubscribeResponse) {}
}
message AddGroupRequest {
Group group = 1;
}
message AddGroupResponse {
Group group = 2;
}
message GetGroupRequest {
string id = 3;
string namespace = 4;
}
message GetGroupResponse {
Group group = 5;
}
message GetGroupsRequest {
repeated string namespaces = 6;
}
message GetGroupsResponse {
repeated Group groups = 7;
}
message GetGroupsBatchRequest {
repeated string groupids = 6;
}
message GetGroupsBatchResponse {
repeated Group groups = 7;
}
message SubscribeRequest {
string groupid = 8;
string memberid = 9;
}
message SubscribeResponse {
bool ok = 10;
}
message UnsubscribeRequest {
string groupid = 11;
string memberid = 12;
}
message UnsubscribeResponse {
bool ok = 13;
}

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: groupsmanagement.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
// GroupsManagementClient is the client API for GroupsManagement 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 GroupsManagementClient interface {
AddGroup(ctx context.Context, in *AddGroupRequest, opts ...grpc.CallOption) (*AddGroupResponse, error)
GetGroup(ctx context.Context, in *GetGroupRequest, opts ...grpc.CallOption) (*GetGroupResponse, error)
GetGroups(ctx context.Context, in *GetGroupsRequest, opts ...grpc.CallOption) (*GetGroupsResponse, error)
GetGroupsBatch(ctx context.Context, in *GetGroupsBatchRequest, opts ...grpc.CallOption) (*GetGroupsBatchResponse, error)
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error)
Unsubscribe(ctx context.Context, in *UnsubscribeRequest, opts ...grpc.CallOption) (*UnsubscribeResponse, error)
}
type groupsManagementClient struct {
cc grpc.ClientConnInterface
}
func NewGroupsManagementClient(cc grpc.ClientConnInterface) GroupsManagementClient {
return &groupsManagementClient{cc}
}
func (c *groupsManagementClient) AddGroup(ctx context.Context, in *AddGroupRequest, opts ...grpc.CallOption) (*AddGroupResponse, error) {
out := new(AddGroupResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/AddGroup", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *groupsManagementClient) GetGroup(ctx context.Context, in *GetGroupRequest, opts ...grpc.CallOption) (*GetGroupResponse, error) {
out := new(GetGroupResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/GetGroup", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *groupsManagementClient) GetGroups(ctx context.Context, in *GetGroupsRequest, opts ...grpc.CallOption) (*GetGroupsResponse, error) {
out := new(GetGroupsResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/GetGroups", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *groupsManagementClient) GetGroupsBatch(ctx context.Context, in *GetGroupsBatchRequest, opts ...grpc.CallOption) (*GetGroupsBatchResponse, error) {
out := new(GetGroupsBatchResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/GetGroupsBatch", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *groupsManagementClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error) {
out := new(SubscribeResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/Subscribe", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *groupsManagementClient) Unsubscribe(ctx context.Context, in *UnsubscribeRequest, opts ...grpc.CallOption) (*UnsubscribeResponse, error) {
out := new(UnsubscribeResponse)
err := c.cc.Invoke(ctx, "/GroupsManagement/Unsubscribe", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GroupsManagementServer is the server API for GroupsManagement service.
// All implementations must embed UnimplementedGroupsManagementServer
// for forward compatibility
type GroupsManagementServer interface {
AddGroup(context.Context, *AddGroupRequest) (*AddGroupResponse, error)
GetGroup(context.Context, *GetGroupRequest) (*GetGroupResponse, error)
GetGroups(context.Context, *GetGroupsRequest) (*GetGroupsResponse, error)
GetGroupsBatch(context.Context, *GetGroupsBatchRequest) (*GetGroupsBatchResponse, error)
Subscribe(context.Context, *SubscribeRequest) (*SubscribeResponse, error)
Unsubscribe(context.Context, *UnsubscribeRequest) (*UnsubscribeResponse, error)
mustEmbedUnimplementedGroupsManagementServer()
}
// UnimplementedGroupsManagementServer must be embedded to have forward compatible implementations.
type UnimplementedGroupsManagementServer struct {
}
func (UnimplementedGroupsManagementServer) AddGroup(context.Context, *AddGroupRequest) (*AddGroupResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddGroup not implemented")
}
func (UnimplementedGroupsManagementServer) GetGroup(context.Context, *GetGroupRequest) (*GetGroupResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetGroup not implemented")
}
func (UnimplementedGroupsManagementServer) GetGroups(context.Context, *GetGroupsRequest) (*GetGroupsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetGroups not implemented")
}
func (UnimplementedGroupsManagementServer) GetGroupsBatch(context.Context, *GetGroupsBatchRequest) (*GetGroupsBatchResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetGroupsBatch not implemented")
}
func (UnimplementedGroupsManagementServer) Subscribe(context.Context, *SubscribeRequest) (*SubscribeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Subscribe not implemented")
}
func (UnimplementedGroupsManagementServer) Unsubscribe(context.Context, *UnsubscribeRequest) (*UnsubscribeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented")
}
func (UnimplementedGroupsManagementServer) mustEmbedUnimplementedGroupsManagementServer() {}
// UnsafeGroupsManagementServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to GroupsManagementServer will
// result in compilation errors.
type UnsafeGroupsManagementServer interface {
mustEmbedUnimplementedGroupsManagementServer()
}
func RegisterGroupsManagementServer(s grpc.ServiceRegistrar, srv GroupsManagementServer) {
s.RegisterService(&GroupsManagement_ServiceDesc, srv)
}
func _GroupsManagement_AddGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddGroupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).AddGroup(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/AddGroup",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).AddGroup(ctx, req.(*AddGroupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GroupsManagement_GetGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetGroupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).GetGroup(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/GetGroup",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).GetGroup(ctx, req.(*GetGroupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GroupsManagement_GetGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetGroupsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).GetGroups(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/GetGroups",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).GetGroups(ctx, req.(*GetGroupsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GroupsManagement_GetGroupsBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetGroupsBatchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).GetGroupsBatch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/GetGroupsBatch",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).GetGroupsBatch(ctx, req.(*GetGroupsBatchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GroupsManagement_Subscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SubscribeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).Subscribe(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/Subscribe",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).Subscribe(ctx, req.(*SubscribeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GroupsManagement_Unsubscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UnsubscribeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GroupsManagementServer).Unsubscribe(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/GroupsManagement/Unsubscribe",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupsManagementServer).Unsubscribe(ctx, req.(*UnsubscribeRequest))
}
return interceptor(ctx, in, info, handler)
}
// GroupsManagement_ServiceDesc is the grpc.ServiceDesc for GroupsManagement service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var GroupsManagement_ServiceDesc = grpc.ServiceDesc{
ServiceName: "GroupsManagement",
HandlerType: (*GroupsManagementServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AddGroup",
Handler: _GroupsManagement_AddGroup_Handler,
},
{
MethodName: "GetGroup",
Handler: _GroupsManagement_GetGroup_Handler,
},
{
MethodName: "GetGroups",
Handler: _GroupsManagement_GetGroups_Handler,
},
{
MethodName: "GetGroupsBatch",
Handler: _GroupsManagement_GetGroupsBatch_Handler,
},
{
MethodName: "Subscribe",
Handler: _GroupsManagement_Subscribe_Handler,
},
{
MethodName: "Unsubscribe",
Handler: _GroupsManagement_Unsubscribe_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "groupsmanagement.proto",
}

124
grpcapi/grpcapi.go Normal file
View File

@@ -0,0 +1,124 @@
package grpcapi
import (
context "context"
"fmt"
"log"
"net"
"git.coopgo.io/coopgo-platform/groups-management/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 GroupsManagementServerImpl struct {
handler handlers.GroupsManagementHandler
}
func NewGroupsManagementServer(h handlers.GroupsManagementHandler) *GroupsManagementServerImpl {
return &GroupsManagementServerImpl{
handler: h,
}
}
func (s GroupsManagementServerImpl) AddGroup(ctx context.Context, req *AddGroupRequest) (*AddGroupResponse, error) {
g := req.Group.ToStorageType()
group, err := s.handler.AddGroup(g)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "group creation failed : %v", err)
}
response, err := GroupFromStorageType(group)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving group : %v", err)
}
return &AddGroupResponse{Group: response}, nil
}
func (s GroupsManagementServerImpl) GetGroup(ctx context.Context, req *GetGroupRequest) (*GetGroupResponse, error) {
group, err := s.handler.GetGroup(req.Id)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "issue while retrieving group : %v", err)
}
response, err := GroupFromStorageType(group)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving group : %v", err)
}
return &GetGroupResponse{Group: response}, nil
}
func (s GroupsManagementServerImpl) GetGroups(ctx context.Context, req *GetGroupsRequest) (*GetGroupsResponse, error) {
responses, err := s.handler.GetGroups(req.Namespaces)
if err != nil {
return nil, status.Errorf(codes.NotFound, "could not get groups : %v", err)
}
var groups []*Group
for _, g := range responses {
group, err := GroupFromStorageType(&g)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get groups : %v", err)
}
groups = append(groups, group)
}
return &GetGroupsResponse{Groups: groups}, nil
}
func (s GroupsManagementServerImpl) GetGroupsBatch(ctx context.Context, req *GetGroupsBatchRequest) (*GetGroupsBatchResponse, error) {
responses, err := s.handler.GetGroupsBatch(req.Groupids)
if err != nil {
return nil, status.Errorf(codes.NotFound, "could not get groups : %v", err)
}
var groups []*Group
for _, g := range responses {
group, err := GroupFromStorageType(&g)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get groups : %v", err)
}
groups = append(groups, group)
}
return &GetGroupsBatchResponse{Groups: groups}, nil
}
func (s GroupsManagementServerImpl) Subscribe(ctx context.Context, req *SubscribeRequest) (*SubscribeResponse, error) {
err := s.handler.Subscribe(req.Groupid, req.Memberid)
if err != nil {
return nil, status.Errorf(codes.AlreadyExists, "could not subscribe : %v", err)
}
return &SubscribeResponse{
Ok: true,
}, nil
}
func (s GroupsManagementServerImpl) Unsubscribe(context.Context, *UnsubscribeRequest) (*UnsubscribeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented")
}
func (s GroupsManagementServerImpl) mustEmbedUnimplementedGroupsManagementServer() {}
func Run(done chan error, cfg *viper.Viper, handler handlers.GroupsManagementHandler) {
var (
dev_env = cfg.GetBool("dev_env")
address = ":" + cfg.GetString("services.grpc.port")
)
fmt.Println("-> GRPC server on", address)
server := grpc.NewServer()
RegisterGroupsManagementServer(server, NewGroupsManagementServer(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
}
}