From 8a03f0281c7d0078d83814657409c396b9470d24 Mon Sep 17 00:00:00 2001 From: Arul Jeyananth James Edison Date: Mon, 18 Jul 2022 08:39:21 +0530 Subject: [PATCH] demo givencode base base line as per demo given for class,tag --- go.mod | 14 +- go.sum | 12 +- src/classifiers/classfication_handler.go | 29 +- src/main.go | 5 +- src/proto/class/class.pb.go | 615 +++++++++++++++++++++++ src/proto/class/class.proto | 57 +++ src/proto/class/class_grpc.pb.go | 177 +++++++ src/proto/tag/tag.pb.go | 613 ++++++++++++++++++++++ src/proto/tag/tag.proto | 57 +++ src/proto/tag/tag_grpc.pb.go | 177 +++++++ src/server/grpcServer.go | 127 +++-- src/storage/internal.go | 39 +- src/storage/storage_handler.go | 16 +- 13 files changed, 1854 insertions(+), 84 deletions(-) create mode 100644 src/proto/class/class.pb.go create mode 100644 src/proto/class/class.proto create mode 100644 src/proto/class/class_grpc.pb.go create mode 100644 src/proto/tag/tag.pb.go create mode 100644 src/proto/tag/tag.proto create mode 100644 src/proto/tag/tag_grpc.pb.go diff --git a/go.mod b/go.mod index 724cf9d..72c9b2e 100644 --- a/go.mod +++ b/go.mod @@ -14,38 +14,30 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/lib/pq v1.10.6 - github.com/mattn/go-isatty v0.0.12 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rs/zerolog v1.27.0 // indirect golang.org/x/mod v0.3.0 // indirect golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/grpc v1.47.0 // indirect - google.golang.org/protobuf v1.28.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect google.golang.org/grpc v1.47.0 - lukechampine.com/uint128 v1.1.1 // indirect + google.golang.org/protobuf v1.28.0 + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + lukechampine.com/uint128 v1.1.1 // indirect modernc.org/cc/v3 v3.36.0 // indirect modernc.org/ccgo/v3 v3.16.6 // indirect modernc.org/libc v1.16.7 // indirect modernc.org/mathutil v1.4.1 // indirect modernc.org/memory v1.1.1 // indirect modernc.org/opt v0.1.1 // indirect - modernc.org/sqlite v1.17.3 modernc.org/strutil v1.1.1 // indirect modernc.org/token v1.0.0 // indirect ) require ( github.com/confluentinc/confluent-kafka-go v1.8.2 - github.com/golang/protobuf v1.5.2 // indirect golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect golang.org/x/text v0.3.3 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index d5a4ef0..a8ee2d0 100644 --- a/go.sum +++ b/go.sum @@ -11,10 +11,10 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/confluentinc/confluent-kafka-go v1.8.2 h1:PBdbvYpyOdFLehj8j+9ba7FL4c4Moxn79gy9cYKxG5E= github.com/confluentinc/confluent-kafka-go v1.8.2/go.mod h1:u2zNLny2xq+5rWeTQjFHbDzzNuba4P1vo31r9r4uAdg= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -88,11 +88,11 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -131,6 +131,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -190,6 +192,8 @@ gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXL gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/src/classifiers/classfication_handler.go b/src/classifiers/classfication_handler.go index ad5b6e8..4535821 100644 --- a/src/classifiers/classfication_handler.go +++ b/src/classifiers/classfication_handler.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "regexp" + "strings" "github.com/datasage-io/datasage/src/adaptors" "github.com/datasage-io/datasage/src/storage" @@ -26,14 +27,6 @@ func Run(dpDataSource DpDataSource) { log.SetFlags(log.LstdFlags | log.Lshortfile) log.Println("Classification Handler Run") //Fetch MetaData - /* - adpt, err := adaptors.New(adaptors.AdaptorConfig{ - Type: "mysql", - Username: "user1", - Password: "Accu0104#", - Host: "localhost"}) - */ - adpt, err := adaptors.New(adaptors.AdaptorConfig{ Type: dpDataSource.Dstype, Username: dpDataSource.User, @@ -141,32 +134,28 @@ func Run(dpDataSource DpDataSource) { //if err != nil { // log.Println(err.Error()) //} - tags := "" - classes := "" + tags := []string{} + classes := []string{} if len(relatedclasses) > 0 { for _, relatedclass := range relatedclasses { log.Println("Class:= ", relatedclass.Class) - classes = classes + ";" + relatedclass.Class + //classes = classes + ";" + relatedclass. + classes = append(classes, relatedclass.Class) } } if len(relatedtags) > 0 { for _, relatedtag := range relatedtags { log.Println("TagName:", relatedtag.TagName) - tags = tags + ";" + relatedtag.TagName + //tags = tags + ";" + relatedtag.TagName + tags = append(tags, relatedtag.TagName) } } - /* - else { - continue - } - */ - col := storage.DpDbColumn{ ColumnName: colName, ColumnType: cols.ColumnType, ColumnComment: cols.ColumnComment, - Tags: tags, - Classes: classes, + Tags: strings.Join(tags, ";"), + Classes: strings.Join(classes, ";"), } dpDbColumns = append(dpDbColumns, col) } diff --git a/src/main.go b/src/main.go index a1c6b9d..3f6a53d 100644 --- a/src/main.go +++ b/src/main.go @@ -9,12 +9,11 @@ import ( func main() { - //Create Server + //Run a gRPC Server for CLI command processing listen, err := net.Listen("tcp", ":"+grpcServer.PortNumber) if err != nil { log.Error().Msgf("gRPC server failed to listen : %v", err) } - server := grpcServer.GetNewServer() //Start service log.Info().Msgf("gRPC server on %s port started", grpcServer.PortNumber) @@ -22,6 +21,4 @@ func main() { log.Error().Msgf("Failed to serve: %v", err) } - //classifiers.Run() - } diff --git a/src/proto/class/class.pb.go b/src/proto/class/class.pb.go new file mode 100644 index 0000000..ab9685b --- /dev/null +++ b/src/proto/class/class.pb.go @@ -0,0 +1,615 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.12.4 +// source: class.proto + +package class + +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) +) + +//Request for Create Class +type CreateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Tag []string `protobuf:"bytes,3,rep,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *CreateRequest) Reset() { + *x = CreateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRequest) ProtoMessage() {} + +func (x *CreateRequest) ProtoReflect() protoreflect.Message { + mi := &file_class_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 CreateRequest.ProtoReflect.Descriptor instead. +func (*CreateRequest) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *CreateRequest) GetTag() []string { + if x != nil { + return x.Tag + } + return nil +} + +//Response for Class +type MessageResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *MessageResponse) Reset() { + *x = MessageResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageResponse) ProtoMessage() {} + +func (x *MessageResponse) ProtoReflect() protoreflect.Message { + mi := &file_class_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 MessageResponse.ProtoReflect.Descriptor instead. +func (*MessageResponse) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{1} +} + +func (x *MessageResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +//List Class Request +type ListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Tag []string `protobuf:"bytes,3,rep,name=tag,proto3" json:"tag,omitempty"` + First int64 `protobuf:"varint,4,opt,name=first,proto3" json:"first,omitempty"` + Last int64 `protobuf:"varint,5,opt,name=last,proto3" json:"last,omitempty"` + Limit int64 `protobuf:"varint,6,opt,name=limit,proto3" json:"limit,omitempty"` + Count bool `protobuf:"varint,7,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_class_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 ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{2} +} + +func (x *ListRequest) GetId() []string { + if x != nil { + return x.Id + } + return nil +} + +func (x *ListRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ListRequest) GetTag() []string { + if x != nil { + return x.Tag + } + return nil +} + +func (x *ListRequest) GetFirst() int64 { + if x != nil { + return x.First + } + return 0 +} + +func (x *ListRequest) GetLast() int64 { + if x != nil { + return x.Last + } + return 0 +} + +func (x *ListRequest) GetLimit() int64 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *ListRequest) GetCount() bool { + if x != nil { + return x.Count + } + return false +} + +//Class Response Structure +type ClassResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Tag string `protobuf:"bytes,4,opt,name=tag,proto3" json:"tag,omitempty"` + CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (x *ClassResponse) Reset() { + *x = ClassResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClassResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClassResponse) ProtoMessage() {} + +func (x *ClassResponse) ProtoReflect() protoreflect.Message { + mi := &file_class_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 ClassResponse.ProtoReflect.Descriptor instead. +func (*ClassResponse) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{3} +} + +func (x *ClassResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ClassResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ClassResponse) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *ClassResponse) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +func (x *ClassResponse) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +//Response to list class +type ListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClassResponse []*ClassResponse `protobuf:"bytes,1,rep,name=classResponse,proto3" json:"classResponse,omitempty"` + Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *ListResponse) Reset() { + *x = ListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse) ProtoMessage() {} + +func (x *ListResponse) ProtoReflect() protoreflect.Message { + mi := &file_class_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 ListResponse.ProtoReflect.Descriptor instead. +func (*ListResponse) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{4} +} + +func (x *ListResponse) GetClassResponse() []*ClassResponse { + if x != nil { + return x.ClassResponse + } + return nil +} + +func (x *ListResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +//Request for Delete class +type DeleteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id,omitempty"` + IsDeleteAll bool `protobuf:"varint,2,opt,name=isDeleteAll,proto3" json:"isDeleteAll,omitempty"` +} + +func (x *DeleteRequest) Reset() { + *x = DeleteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_class_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequest) ProtoMessage() {} + +func (x *DeleteRequest) ProtoReflect() protoreflect.Message { + mi := &file_class_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 DeleteRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return file_class_proto_rawDescGZIP(), []int{5} +} + +func (x *DeleteRequest) GetId() []string { + if x != nil { + return x.Id + } + return nil +} + +func (x *DeleteRequest) GetIsDeleteAll() bool { + if x != nil { + return x.IsDeleteAll + } + return false +} + +var File_class_proto protoreflect.FileDescriptor + +var file_class_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x63, + 0x6c, 0x61, 0x73, 0x73, 0x22, 0x57, 0x0a, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 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, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x74, + 0x61, 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x2b, 0x0a, + 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x99, 0x01, 0x0a, 0x0b, 0x6c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, + 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, + 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x86, 0x01, 0x0a, 0x0d, 0x43, 0x6c, 0x61, 0x73, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, + 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, + 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, + 0x60, 0x0a, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3a, 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x43, + 0x6c, 0x61, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0d, 0x63, 0x6c, + 0x61, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x41, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x6c, + 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x41, 0x6c, 0x6c, 0x32, 0xb4, 0x01, 0x0a, 0x05, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x38, + 0x0a, 0x08, 0x41, 0x64, 0x64, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x14, 0x2e, 0x63, 0x6c, 0x61, + 0x73, 0x73, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, + 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x12, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x6c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x63, 0x6c, 0x61, 0x73, + 0x73, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, + 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x14, 0x2e, + 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x61, + 0x67, 0x65, 0x2d, 0x69, 0x6f, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_class_proto_rawDescOnce sync.Once + file_class_proto_rawDescData = file_class_proto_rawDesc +) + +func file_class_proto_rawDescGZIP() []byte { + file_class_proto_rawDescOnce.Do(func() { + file_class_proto_rawDescData = protoimpl.X.CompressGZIP(file_class_proto_rawDescData) + }) + return file_class_proto_rawDescData +} + +var file_class_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_class_proto_goTypes = []interface{}{ + (*CreateRequest)(nil), // 0: class.createRequest + (*MessageResponse)(nil), // 1: class.messageResponse + (*ListRequest)(nil), // 2: class.listRequest + (*ClassResponse)(nil), // 3: class.ClassResponse + (*ListResponse)(nil), // 4: class.listResponse + (*DeleteRequest)(nil), // 5: class.deleteRequest +} +var file_class_proto_depIdxs = []int32{ + 3, // 0: class.listResponse.classResponse:type_name -> class.ClassResponse + 0, // 1: class.Class.AddClass:input_type -> class.createRequest + 2, // 2: class.Class.ListClass:input_type -> class.listRequest + 5, // 3: class.Class.DeleteClass:input_type -> class.deleteRequest + 1, // 4: class.Class.AddClass:output_type -> class.messageResponse + 4, // 5: class.Class.ListClass:output_type -> class.listResponse + 1, // 6: class.Class.DeleteClass:output_type -> class.messageResponse + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] 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_class_proto_init() } +func file_class_proto_init() { + if File_class_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_class_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_class_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_class_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_class_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClassResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_class_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_class_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRequest); 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_class_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_class_proto_goTypes, + DependencyIndexes: file_class_proto_depIdxs, + MessageInfos: file_class_proto_msgTypes, + }.Build() + File_class_proto = out.File + file_class_proto_rawDesc = nil + file_class_proto_goTypes = nil + file_class_proto_depIdxs = nil +} diff --git a/src/proto/class/class.proto b/src/proto/class/class.proto new file mode 100644 index 0000000..364d95f --- /dev/null +++ b/src/proto/class/class.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; + +package class; + +option go_package = "github.com/datasage-io/datasage/proto/class"; + + +//RPC Service +service Class { + rpc AddClass ( createRequest ) returns ( messageResponse ); + rpc ListClass( listRequest ) returns ( listResponse ); + rpc DeleteClass ( deleteRequest ) returns ( messageResponse ); +} + +//Request for Create Class +message createRequest { + string name = 1; + string description = 2; + repeated string tag = 3; +} + +//Response for Class +message messageResponse { + string message = 1; +} + +//List Class Request +message listRequest { + repeated string id = 1; + string name = 2; + repeated string tag = 3; + int64 first = 4; + int64 last = 5; + int64 limit = 6; + bool count = 7; +} + +//Class Response Structure +message ClassResponse { + string id = 1; + string name = 2; + string description = 3; + string tag = 4; + string created_at = 6; +} + +//Response to list class +message listResponse { + repeated ClassResponse classResponse = 1; + int64 count = 2; +} + +//Request for Delete class +message deleteRequest { + repeated string id = 1; + bool isDeleteAll = 2; +} \ No newline at end of file diff --git a/src/proto/class/class_grpc.pb.go b/src/proto/class/class_grpc.pb.go new file mode 100644 index 0000000..516a865 --- /dev/null +++ b/src/proto/class/class_grpc.pb.go @@ -0,0 +1,177 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.12.4 +// source: class.proto + +package class + +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 + +// ClassClient is the client API for Class 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 ClassClient interface { + AddClass(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*MessageResponse, error) + ListClass(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) + DeleteClass(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*MessageResponse, error) +} + +type classClient struct { + cc grpc.ClientConnInterface +} + +func NewClassClient(cc grpc.ClientConnInterface) ClassClient { + return &classClient{cc} +} + +func (c *classClient) AddClass(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*MessageResponse, error) { + out := new(MessageResponse) + err := c.cc.Invoke(ctx, "/class.Class/AddClass", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *classClient) ListClass(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { + out := new(ListResponse) + err := c.cc.Invoke(ctx, "/class.Class/ListClass", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *classClient) DeleteClass(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*MessageResponse, error) { + out := new(MessageResponse) + err := c.cc.Invoke(ctx, "/class.Class/DeleteClass", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ClassServer is the server API for Class service. +// All implementations must embed UnimplementedClassServer +// for forward compatibility +type ClassServer interface { + AddClass(context.Context, *CreateRequest) (*MessageResponse, error) + ListClass(context.Context, *ListRequest) (*ListResponse, error) + DeleteClass(context.Context, *DeleteRequest) (*MessageResponse, error) + mustEmbedUnimplementedClassServer() +} + +// UnimplementedClassServer must be embedded to have forward compatible implementations. +type UnimplementedClassServer struct { +} + +func (UnimplementedClassServer) AddClass(context.Context, *CreateRequest) (*MessageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddClass not implemented") +} +func (UnimplementedClassServer) ListClass(context.Context, *ListRequest) (*ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListClass not implemented") +} +func (UnimplementedClassServer) DeleteClass(context.Context, *DeleteRequest) (*MessageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteClass not implemented") +} +func (UnimplementedClassServer) mustEmbedUnimplementedClassServer() {} + +// UnsafeClassServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ClassServer will +// result in compilation errors. +type UnsafeClassServer interface { + mustEmbedUnimplementedClassServer() +} + +func RegisterClassServer(s grpc.ServiceRegistrar, srv ClassServer) { + s.RegisterService(&Class_ServiceDesc, srv) +} + +func _Class_AddClass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClassServer).AddClass(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/class.Class/AddClass", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClassServer).AddClass(ctx, req.(*CreateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Class_ListClass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClassServer).ListClass(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/class.Class/ListClass", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClassServer).ListClass(ctx, req.(*ListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Class_DeleteClass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClassServer).DeleteClass(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/class.Class/DeleteClass", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClassServer).DeleteClass(ctx, req.(*DeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Class_ServiceDesc is the grpc.ServiceDesc for Class service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Class_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "class.Class", + HandlerType: (*ClassServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddClass", + Handler: _Class_AddClass_Handler, + }, + { + MethodName: "ListClass", + Handler: _Class_ListClass_Handler, + }, + { + MethodName: "DeleteClass", + Handler: _Class_DeleteClass_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "class.proto", +} diff --git a/src/proto/tag/tag.pb.go b/src/proto/tag/tag.pb.go new file mode 100644 index 0000000..3a12468 --- /dev/null +++ b/src/proto/tag/tag.pb.go @@ -0,0 +1,613 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.12.4 +// source: tag.proto + +package tag + +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) +) + +//Request for Add Tag +type AddRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Class []string `protobuf:"bytes,3,rep,name=class,proto3" json:"class,omitempty"` +} + +func (x *AddRequest) Reset() { + *x = AddRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddRequest) ProtoMessage() {} + +func (x *AddRequest) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 AddRequest.ProtoReflect.Descriptor instead. +func (*AddRequest) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{0} +} + +func (x *AddRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *AddRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *AddRequest) GetClass() []string { + if x != nil { + return x.Class + } + return nil +} + +//Response for Tag +type MessageResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *MessageResponse) Reset() { + *x = MessageResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageResponse) ProtoMessage() {} + +func (x *MessageResponse) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 MessageResponse.ProtoReflect.Descriptor instead. +func (*MessageResponse) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{1} +} + +func (x *MessageResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +//List Tag Request +type ListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Class []string `protobuf:"bytes,3,rep,name=class,proto3" json:"class,omitempty"` + First int64 `protobuf:"varint,4,opt,name=first,proto3" json:"first,omitempty"` + Last int64 `protobuf:"varint,5,opt,name=last,proto3" json:"last,omitempty"` + Limit int64 `protobuf:"varint,6,opt,name=limit,proto3" json:"limit,omitempty"` + Count bool `protobuf:"varint,7,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{2} +} + +func (x *ListRequest) GetId() []string { + if x != nil { + return x.Id + } + return nil +} + +func (x *ListRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ListRequest) GetClass() []string { + if x != nil { + return x.Class + } + return nil +} + +func (x *ListRequest) GetFirst() int64 { + if x != nil { + return x.First + } + return 0 +} + +func (x *ListRequest) GetLast() int64 { + if x != nil { + return x.Last + } + return 0 +} + +func (x *ListRequest) GetLimit() int64 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *ListRequest) GetCount() bool { + if x != nil { + return x.Count + } + return false +} + +//Tag Response Structure +type TagResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Class []string `protobuf:"bytes,4,rep,name=class,proto3" json:"class,omitempty"` + CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (x *TagResponse) Reset() { + *x = TagResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TagResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TagResponse) ProtoMessage() {} + +func (x *TagResponse) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 TagResponse.ProtoReflect.Descriptor instead. +func (*TagResponse) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{3} +} + +func (x *TagResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *TagResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TagResponse) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *TagResponse) GetClass() []string { + if x != nil { + return x.Class + } + return nil +} + +func (x *TagResponse) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +//Response to list tag +type ListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TagResponse []*TagResponse `protobuf:"bytes,1,rep,name=tagResponse,proto3" json:"tagResponse,omitempty"` + Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *ListResponse) Reset() { + *x = ListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse) ProtoMessage() {} + +func (x *ListResponse) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 ListResponse.ProtoReflect.Descriptor instead. +func (*ListResponse) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{4} +} + +func (x *ListResponse) GetTagResponse() []*TagResponse { + if x != nil { + return x.TagResponse + } + return nil +} + +func (x *ListResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +//Request for Delete tag +type DeleteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []string `protobuf:"bytes,1,rep,name=id,proto3" json:"id,omitempty"` + IsDeleteAll bool `protobuf:"varint,2,opt,name=isDeleteAll,proto3" json:"isDeleteAll,omitempty"` +} + +func (x *DeleteRequest) Reset() { + *x = DeleteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_tag_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequest) ProtoMessage() {} + +func (x *DeleteRequest) ProtoReflect() protoreflect.Message { + mi := &file_tag_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 DeleteRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return file_tag_proto_rawDescGZIP(), []int{5} +} + +func (x *DeleteRequest) GetId() []string { + if x != nil { + return x.Id + } + return nil +} + +func (x *DeleteRequest) GetIsDeleteAll() bool { + if x != nil { + return x.IsDeleteAll + } + return false +} + +var File_tag_proto protoreflect.FileDescriptor + +var file_tag_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x74, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x74, 0x61, 0x67, + 0x22, 0x58, 0x0a, 0x0a, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 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, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x2b, 0x0a, 0x0f, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x9d, 0x01, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, + 0x6c, 0x61, 0x73, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6c, 0x61, 0x73, + 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, + 0x69, 0x6d, 0x69, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x88, 0x01, 0x0a, 0x0b, 0x54, 0x61, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6c, + 0x61, 0x73, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x41, 0x74, 0x22, 0x58, 0x0a, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x32, 0x0a, 0x0b, 0x74, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x54, 0x61, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0b, 0x74, 0x61, 0x67, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x41, 0x0a, 0x0d, + 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, + 0x0b, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x6c, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x6c, 0x6c, 0x32, + 0x9d, 0x01, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x41, 0x64, 0x64, 0x54, 0x61, + 0x67, 0x12, 0x0f, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, + 0x54, 0x61, 0x67, 0x12, 0x10, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x6c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x09, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x54, 0x61, 0x67, 0x12, 0x12, 0x2e, 0x74, 0x61, 0x67, 0x2e, 0x64, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x74, 0x61, 0x67, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, + 0x74, 0x61, 0x73, 0x61, 0x67, 0x65, 0x2d, 0x69, 0x6f, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x73, 0x61, + 0x67, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x61, 0x67, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_tag_proto_rawDescOnce sync.Once + file_tag_proto_rawDescData = file_tag_proto_rawDesc +) + +func file_tag_proto_rawDescGZIP() []byte { + file_tag_proto_rawDescOnce.Do(func() { + file_tag_proto_rawDescData = protoimpl.X.CompressGZIP(file_tag_proto_rawDescData) + }) + return file_tag_proto_rawDescData +} + +var file_tag_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_tag_proto_goTypes = []interface{}{ + (*AddRequest)(nil), // 0: tag.addRequest + (*MessageResponse)(nil), // 1: tag.messageResponse + (*ListRequest)(nil), // 2: tag.listRequest + (*TagResponse)(nil), // 3: tag.TagResponse + (*ListResponse)(nil), // 4: tag.listResponse + (*DeleteRequest)(nil), // 5: tag.deleteRequest +} +var file_tag_proto_depIdxs = []int32{ + 3, // 0: tag.listResponse.tagResponse:type_name -> tag.TagResponse + 0, // 1: tag.Tag.AddTag:input_type -> tag.addRequest + 2, // 2: tag.Tag.ListTag:input_type -> tag.listRequest + 5, // 3: tag.Tag.DeleteTag:input_type -> tag.deleteRequest + 1, // 4: tag.Tag.AddTag:output_type -> tag.messageResponse + 4, // 5: tag.Tag.ListTag:output_type -> tag.listResponse + 1, // 6: tag.Tag.DeleteTag:output_type -> tag.messageResponse + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] 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_tag_proto_init() } +func file_tag_proto_init() { + if File_tag_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_tag_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_tag_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_tag_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_tag_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TagResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_tag_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_tag_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRequest); 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_tag_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_tag_proto_goTypes, + DependencyIndexes: file_tag_proto_depIdxs, + MessageInfos: file_tag_proto_msgTypes, + }.Build() + File_tag_proto = out.File + file_tag_proto_rawDesc = nil + file_tag_proto_goTypes = nil + file_tag_proto_depIdxs = nil +} diff --git a/src/proto/tag/tag.proto b/src/proto/tag/tag.proto new file mode 100644 index 0000000..111a3c5 --- /dev/null +++ b/src/proto/tag/tag.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; + +package tag; + +option go_package = "github.com/datasage-io/datasage/proto/tag"; + + +//RPC Service +service Tag { + rpc AddTag ( addRequest ) returns ( messageResponse ); + rpc ListTag( listRequest ) returns ( listResponse ); + rpc DeleteTag ( deleteRequest ) returns ( messageResponse ); +} + +//Request for Add Tag +message addRequest { + string name = 1; + string description = 2; + repeated string class = 3; +} + +//Response for Tag +message messageResponse { + string message = 1; +} + +//List Tag Request +message listRequest { + repeated string id = 1; + string name = 2; + repeated string class = 3; + int64 first = 4; + int64 last = 5; + int64 limit = 6; + bool count = 7; +} + +//Tag Response Structure +message TagResponse { + string id = 1; + string name = 2; + string description = 3; + repeated string class = 4; + string created_at = 6; +} + +//Response to list tag +message listResponse { + repeated TagResponse tagResponse = 1; + int64 count = 2; +} + +//Request for Delete tag +message deleteRequest { + repeated string id = 1; + bool isDeleteAll = 2; +} \ No newline at end of file diff --git a/src/proto/tag/tag_grpc.pb.go b/src/proto/tag/tag_grpc.pb.go new file mode 100644 index 0000000..de03507 --- /dev/null +++ b/src/proto/tag/tag_grpc.pb.go @@ -0,0 +1,177 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.12.4 +// source: tag.proto + +package tag + +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 + +// TagClient is the client API for Tag 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 TagClient interface { + AddTag(ctx context.Context, in *AddRequest, opts ...grpc.CallOption) (*MessageResponse, error) + ListTag(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) + DeleteTag(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*MessageResponse, error) +} + +type tagClient struct { + cc grpc.ClientConnInterface +} + +func NewTagClient(cc grpc.ClientConnInterface) TagClient { + return &tagClient{cc} +} + +func (c *tagClient) AddTag(ctx context.Context, in *AddRequest, opts ...grpc.CallOption) (*MessageResponse, error) { + out := new(MessageResponse) + err := c.cc.Invoke(ctx, "/tag.Tag/AddTag", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tagClient) ListTag(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { + out := new(ListResponse) + err := c.cc.Invoke(ctx, "/tag.Tag/ListTag", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tagClient) DeleteTag(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*MessageResponse, error) { + out := new(MessageResponse) + err := c.cc.Invoke(ctx, "/tag.Tag/DeleteTag", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TagServer is the server API for Tag service. +// All implementations must embed UnimplementedTagServer +// for forward compatibility +type TagServer interface { + AddTag(context.Context, *AddRequest) (*MessageResponse, error) + ListTag(context.Context, *ListRequest) (*ListResponse, error) + DeleteTag(context.Context, *DeleteRequest) (*MessageResponse, error) + mustEmbedUnimplementedTagServer() +} + +// UnimplementedTagServer must be embedded to have forward compatible implementations. +type UnimplementedTagServer struct { +} + +func (UnimplementedTagServer) AddTag(context.Context, *AddRequest) (*MessageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddTag not implemented") +} +func (UnimplementedTagServer) ListTag(context.Context, *ListRequest) (*ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListTag not implemented") +} +func (UnimplementedTagServer) DeleteTag(context.Context, *DeleteRequest) (*MessageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteTag not implemented") +} +func (UnimplementedTagServer) mustEmbedUnimplementedTagServer() {} + +// UnsafeTagServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TagServer will +// result in compilation errors. +type UnsafeTagServer interface { + mustEmbedUnimplementedTagServer() +} + +func RegisterTagServer(s grpc.ServiceRegistrar, srv TagServer) { + s.RegisterService(&Tag_ServiceDesc, srv) +} + +func _Tag_AddTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TagServer).AddTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tag.Tag/AddTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TagServer).AddTag(ctx, req.(*AddRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Tag_ListTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TagServer).ListTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tag.Tag/ListTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TagServer).ListTag(ctx, req.(*ListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Tag_DeleteTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TagServer).DeleteTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tag.Tag/DeleteTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TagServer).DeleteTag(ctx, req.(*DeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Tag_ServiceDesc is the grpc.ServiceDesc for Tag service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Tag_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "tag.Tag", + HandlerType: (*TagServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddTag", + Handler: _Tag_AddTag_Handler, + }, + { + MethodName: "ListTag", + Handler: _Tag_ListTag_Handler, + }, + { + MethodName: "DeleteTag", + Handler: _Tag_DeleteTag_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tag.proto", +} diff --git a/src/server/grpcServer.go b/src/server/grpcServer.go index 0cc85b0..d7b8aab 100644 --- a/src/server/grpcServer.go +++ b/src/server/grpcServer.go @@ -9,7 +9,10 @@ import ( dpclassifcation "github.com/datasage-io/datasage/src/classifiers" logger "github.com/datasage-io/datasage/src/logger" + classpb "github.com/datasage-io/datasage/src/proto/class" ds "github.com/datasage-io/datasage/src/proto/datasource" + tagpb "github.com/datasage-io/datasage/src/proto/tag" + "github.com/datasage-io/datasage/src/storage" "github.com/google/uuid" "github.com/rs/zerolog" "google.golang.org/grpc" @@ -30,53 +33,108 @@ type DatasourceServer struct { ds.UnimplementedDatasourceServer } -/* -func (s *DatasourceServer) AddDatasources(ctx context.Context, in *pb.AddDatasourceRequest, opts ...grpc.CallOption) (pb.Datasource_AddDatasourcesClient, error) { - log.Trace().Msg("AddDatasources") +type TagServer struct { + tagpb.UnimplementedTagServer +} + +type ClassServer struct { + classpb.UnimplementedClassServer +} + +func (d *ClassServer) AddClass(ctx context.Context, in *classpb.CreateRequest) (*classpb.MessageResponse, error) { + fmt.Println("AddClass : ", in) return nil, nil } -func (s *DatasourceServer) ListDatasources(ctx context.Context, in *pb.ListDatasourceRequest, opts ...grpc.CallOption) (pb.Datasource_ListDatasourcesClient, error) { +func (d *ClassServer) ListClass(ctx context.Context, in *classpb.ListRequest) (*classpb.ListResponse, error) { + fmt.Println("ListClass : ", in) + + st, err := storage.GetStorageInstance() + if err != nil { + log.Error().Err(err).Msg("Internal Error") + } + + classes, _ := st.GetClasses() + classesOut := []*classpb.ClassResponse{} + for _, class := range classes { + log.Debug().Msgf("ListTag %v", class) + //classes := []string{tag.Rule} + classOut := &classpb.ClassResponse{ + Id: strconv.Itoa(class.Id), + Name: class.Rule, + Description: class.Description, + Tag: "", + CreatedAt: "", + } + classesOut = append(classesOut, classOut) + + } + return &classpb.ListResponse{ClassResponse: classesOut, Count: int64(len(classesOut))}, nil + return nil, nil } -func (s *DatasourceServer) DeleteDatasources(ctx context.Context, in *pb.DeleteDatasourceRequest, opts ...grpc.CallOption) (pb.Datasource_DeleteDatasourcesClient, error) { +func (d *ClassServer) DeleteClass(ctx context.Context, in *classpb.DeleteRequest) (*classpb.MessageResponse, error) { + fmt.Println("DeleteClass : ", in) return nil, nil } -*/ -/* -func (s *DatasourceServer) AddDatasources(in *pb.AddDatasourceRequest, stream pb.Datasource_AddDatasourcesServer) error { - log.Trace().Msg("AddDatasources Enter") - dpDataSource := dpclassifcation.DpDataSource{ - Datadomain: in.GetDataDomain(), - Dsname: in.GetDsName(), - Dsdecription: in.GetDsDescription(), - Dstype: in.GetDsType(), - Dsversion: in.GetDsVersion(), - Host: in.GetHost(), - Port: in.GetPort(), - User: in.GetUser(), - Password: in.GetPassword(), - DsKey: uuid.New().String(), - } +func (d *TagServer) AddTag(ctx context.Context, in *tagpb.AddRequest) (*tagpb.MessageResponse, error) { + log.Debug().Msgf("AddTag %v", in) + + st, err := storage.GetStorageInstance() + if err != nil { + log.Error().Err(err).Msg("Internal Error") + } else { + var classesAsscociated []string + classes := in.GetClass() + + log.Debug().Msgf("classes %v", classes) - dpclassifcation.Run(dpDataSource) + for _, className := range classes { + log.Debug().Msgf("AddTag className %v", className) + classesAsscociated = append(classesAsscociated, className) + } + log.Debug().Msgf("array %v", classesAsscociated) + + err1 := st.AddTag(in.GetName(), in.GetDescription(), classesAsscociated) + if err1 != nil { + log.Error().Err(err).Msg("Internal Error") + return &tagpb.MessageResponse{Message: "Error in adding Tag"}, nil + } + } + return &tagpb.MessageResponse{Message: "Tag Added sucessfully"}, nil - log.Trace().Msg("AddDatasources Exit") - return nil } +func (d *TagServer) ListTag(ctx context.Context, in *tagpb.ListRequest) (*tagpb.ListResponse, error) { + log.Debug().Msgf("ListTag %v", in) -func (s *DatasourceServer) ListDatasources(*pb.ListDatasourceRequest, pb.Datasource_ListDatasourcesServer) error { - log.Trace().Msg("ListDatasources") - dpclassifcation.ListDatasources() - return nil + st, err := storage.GetStorageInstance() + if err != nil { + log.Error().Err(err).Msg("Internal Error") + } + + tags, _ := st.GetTags() + tagsOut := []*tagpb.TagResponse{} + + for _, tag := range tags { + log.Debug().Msgf("ListTag %v", tag) + classes := []string{tag.Rule} + tagOut := &tagpb.TagResponse{ + Id: strconv.Itoa(tag.Id), + Name: tag.TagName, + Description: tag.Description, + Class: classes, + CreatedAt: "", + } + tagsOut = append(tagsOut, tagOut) + + } + return &tagpb.ListResponse{TagResponse: tagsOut, Count: int64(len(tagsOut))}, nil } -func (s *DatasourceServer) DeleteDatasources(*pb.DeleteDatasourceRequest, pb.Datasource_DeleteDatasourcesServer) error { - log.Trace().Msg("DeleteDatasources") - dpclassifcation.DeleteDatasources() - return nil +func (d *TagServer) DeleteTag(ctx context.Context, in *tagpb.DeleteRequest) (*tagpb.MessageResponse, error) { + log.Debug().Msgf("DeleteTag %v", in) + return nil, nil } -*/ func (d *DatasourceServer) AddDatasource(ctx context.Context, in *ds.AddRequest) (*ds.MessageResponse, error) { fmt.Println("Add Datasource Request --- ", in) @@ -152,5 +210,8 @@ func GetNewServer() *grpc.Server { //Create Server Instance //Register gRPC Server ds.RegisterDatasourceServer(s, &DatasourceServer{}) + tagpb.RegisterTagServer(s, &TagServer{}) + classpb.RegisterClassServer(s, &ClassServer{}) + return s } diff --git a/src/storage/internal.go b/src/storage/internal.go index 3fcbcea..e38e893 100644 --- a/src/storage/internal.go +++ b/src/storage/internal.go @@ -21,25 +21,26 @@ func (into InternalStorage) InsertDefaultData(tags []*Tag, classes []*Class) err } tagInsert, err := into.SqliteConnc.Prepare(` - INSERT INTO tag ("id","tag_name","rule","description") - VALUES (?,?,?,?); + INSERT INTO tag ("tag_name","rule","description") + VALUES (?,?,?); `) defer tagInsert.Close() for _, t := range tags { - _, err = tagInsert.Exec(t.Id, t.TagName, t.Rule, t.Description) + _, err = tagInsert.Exec(t.TagName, t.Rule, t.Description) } classInsert, err := into.SqliteConnc.Prepare(` - INSERT INTO class ("id","description","rule","class") - VALUES (?,?,?,?); + INSERT INTO class ("description","rule","class") + VALUES (?,?,?); `) defer classInsert.Close() for _, c := range classes { - _, err = classInsert.Exec(c.Id, c.Description, c.Rule, c.Class) + _, err = classInsert.Exec(c.Description, c.Rule, c.Class) } return err } + func (into InternalStorage) SetDpDataSourceData(dpDataSource DpDataSource) error { dbInsert, errP := into.SqliteConnc.Prepare(` @@ -226,6 +227,32 @@ func NewInternalStorage(dsn string) (InternalStorage, error) { } +func (insto InternalStorage) AddTag(name string, description string, rules []string) error { + log.Println("AddTag ") + tagInsert, err := insto.SqliteConnc.Prepare(` + INSERT INTO tag ("tag_name","description","rule") + VALUES (?,?,?); + `) + if err != nil { + return err + } + //defer tagInsert.Close() + for _, rule := range rules { + log.Println("AddTag rule: %v ", rule) + _, err = tagInsert.Exec(name, description, rule) + if err != nil { + return err + } + } + tagInsert.Close() + log.Println("AddTag done") + return nil +} + +func (insto InternalStorage) DeleteTag(id int64) error { + return nil +} + func (insto InternalStorage) GetTags() ([]Tag, error) { tags := []Tag{} diff --git a/src/storage/storage_handler.go b/src/storage/storage_handler.go index 20cc19a..641ae86 100644 --- a/src/storage/storage_handler.go +++ b/src/storage/storage_handler.go @@ -12,18 +12,16 @@ import ( var initSchema = ` CREATE TABLE IF NOT EXISTS "class" ( - "id" INTEGER, + "id" INTEGER PRIMARY KEY AUTOINCREMENT, "description" TEXT, "rule" TEXT, - "class" TEXT, - PRIMARY KEY("id") + "class" TEXT ); CREATE TABLE IF NOT EXISTS "tag" ( - "id" INTEGER, + "id" INTEGER PRIMARY KEY AUTOINCREMENT, "tag_name" TEXT, "rule" TEXT, - "description" TEXT, - PRIMARY KEY("id") + "description" TEXT ); CREATE TABLE IF NOT EXISTS "dp_databases" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, @@ -80,6 +78,8 @@ type StorageConfig struct { type Storage interface { GetClasses() ([]Class, error) GetTags() ([]Tag, error) + AddTag(string, string, []string) error + GetAssociatedTags(string) ([]Tag, error) GetAssociatedClasses(string) ([]Class, error) SetSchemaData(DpDbDatabase) error @@ -219,6 +219,10 @@ func GetAllDefaultClassAndTags() ([]*Tag, []*Class, error) { } return tags, classes, nil } +func GetStorageInstance() (Storage, error) { + return New(StorageConfig{Type: "internal", Path: "datasageD.db"}) + +} func New(config StorageConfig) (Storage, error) { switch config.Type {