Commit f676d4b7 authored by Kunal Taitkar's avatar Kunal Taitkar
Browse files

Branch changes added in grpc

parent f2328437
Branches
Tags MEP19.03.2020
3 merge requests!220Release v2.0.0 alpha,!219Add: Support for branches,!215Branch changes added in grpc
Showing with 72 additions and 41 deletions
#!/bin/bash or zsh #!/bin/bash or zsh
protoc grpcbuilder/grpcbuildermdl.proto --go_out=plugins=grpc:. protoc grpcbuildermdl/grpcbuildermdl.proto --go_out=plugins=grpc:.
\ No newline at end of file \ No newline at end of file
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: grpcbuildermdl.proto // source: grpcbuildermdl/grpcbuildermdl.proto
package grpcbuildermdl package grpcbuildermdl
...@@ -30,6 +30,7 @@ type GRPCMessage struct { ...@@ -30,6 +30,7 @@ type GRPCMessage struct {
IsRestricted bool `protobuf:"varint,3,opt,name=isRestricted,proto3" json:"isRestricted,omitempty"` IsRestricted bool `protobuf:"varint,3,opt,name=isRestricted,proto3" json:"isRestricted,omitempty"`
IsRoleBased bool `protobuf:"varint,4,opt,name=isRoleBased,proto3" json:"isRoleBased,omitempty"` IsRoleBased bool `protobuf:"varint,4,opt,name=isRoleBased,proto3" json:"isRoleBased,omitempty"`
Token string `protobuf:"bytes,5,opt,name=token,proto3" json:"token,omitempty"` Token string `protobuf:"bytes,5,opt,name=token,proto3" json:"token,omitempty"`
Branch string `protobuf:"bytes,6,opt,name=branch,proto3" json:"branch,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -39,7 +40,7 @@ func (m *GRPCMessage) Reset() { *m = GRPCMessage{} } ...@@ -39,7 +40,7 @@ func (m *GRPCMessage) Reset() { *m = GRPCMessage{} }
func (m *GRPCMessage) String() string { return proto.CompactTextString(m) } func (m *GRPCMessage) String() string { return proto.CompactTextString(m) }
func (*GRPCMessage) ProtoMessage() {} func (*GRPCMessage) ProtoMessage() {}
func (*GRPCMessage) Descriptor() ([]byte, []int) { func (*GRPCMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_8d80590c423530f2, []int{0} return fileDescriptor_e620ca3a5f127fa1, []int{0}
} }
func (m *GRPCMessage) XXX_Unmarshal(b []byte) error { func (m *GRPCMessage) XXX_Unmarshal(b []byte) error {
...@@ -95,6 +96,13 @@ func (m *GRPCMessage) GetToken() string { ...@@ -95,6 +96,13 @@ func (m *GRPCMessage) GetToken() string {
return "" return ""
} }
func (m *GRPCMessage) GetBranch() string {
if m != nil {
return m.Branch
}
return ""
}
type GRPCRequest struct { type GRPCRequest struct {
GrpcMessage *GRPCMessage `protobuf:"bytes,1,opt,name=grpcMessage,proto3" json:"grpcMessage,omitempty"` GrpcMessage *GRPCMessage `protobuf:"bytes,1,opt,name=grpcMessage,proto3" json:"grpcMessage,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
...@@ -106,7 +114,7 @@ func (m *GRPCRequest) Reset() { *m = GRPCRequest{} } ...@@ -106,7 +114,7 @@ func (m *GRPCRequest) Reset() { *m = GRPCRequest{} }
func (m *GRPCRequest) String() string { return proto.CompactTextString(m) } func (m *GRPCRequest) String() string { return proto.CompactTextString(m) }
func (*GRPCRequest) ProtoMessage() {} func (*GRPCRequest) ProtoMessage() {}
func (*GRPCRequest) Descriptor() ([]byte, []int) { func (*GRPCRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8d80590c423530f2, []int{1} return fileDescriptor_e620ca3a5f127fa1, []int{1}
} }
func (m *GRPCRequest) XXX_Unmarshal(b []byte) error { func (m *GRPCRequest) XXX_Unmarshal(b []byte) error {
...@@ -145,7 +153,7 @@ func (m *GRPCResponse) Reset() { *m = GRPCResponse{} } ...@@ -145,7 +153,7 @@ func (m *GRPCResponse) Reset() { *m = GRPCResponse{} }
func (m *GRPCResponse) String() string { return proto.CompactTextString(m) } func (m *GRPCResponse) String() string { return proto.CompactTextString(m) }
func (*GRPCResponse) ProtoMessage() {} func (*GRPCResponse) ProtoMessage() {}
func (*GRPCResponse) Descriptor() ([]byte, []int) { func (*GRPCResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8d80590c423530f2, []int{2} return fileDescriptor_e620ca3a5f127fa1, []int{2}
} }
func (m *GRPCResponse) XXX_Unmarshal(b []byte) error { func (m *GRPCResponse) XXX_Unmarshal(b []byte) error {
...@@ -186,7 +194,7 @@ func (m *GRPCByteResponse) Reset() { *m = GRPCByteResponse{} } ...@@ -186,7 +194,7 @@ func (m *GRPCByteResponse) Reset() { *m = GRPCByteResponse{} }
func (m *GRPCByteResponse) String() string { return proto.CompactTextString(m) } func (m *GRPCByteResponse) String() string { return proto.CompactTextString(m) }
func (*GRPCByteResponse) ProtoMessage() {} func (*GRPCByteResponse) ProtoMessage() {}
func (*GRPCByteResponse) Descriptor() ([]byte, []int) { func (*GRPCByteResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8d80590c423530f2, []int{3} return fileDescriptor_e620ca3a5f127fa1, []int{3}
} }
func (m *GRPCByteResponse) XXX_Unmarshal(b []byte) error { func (m *GRPCByteResponse) XXX_Unmarshal(b []byte) error {
...@@ -235,39 +243,42 @@ func init() { ...@@ -235,39 +243,42 @@ func init() {
proto.RegisterType((*GRPCByteResponse)(nil), "grpcbuildermdl.GRPCByteResponse") proto.RegisterType((*GRPCByteResponse)(nil), "grpcbuildermdl.GRPCByteResponse")
} }
func init() { proto.RegisterFile("grpcbuildermdl.proto", fileDescriptor_8d80590c423530f2) } func init() {
proto.RegisterFile("grpcbuildermdl/grpcbuildermdl.proto", fileDescriptor_e620ca3a5f127fa1)
var fileDescriptor_8d80590c423530f2 = []byte{ }
// 308 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xb1, 0x4e, 0xf3, 0x30, var fileDescriptor_e620ca3a5f127fa1 = []byte{
0x14, 0x85, 0xff, 0xfc, 0xb4, 0x88, 0xdc, 0x54, 0xa8, 0xb2, 0x3a, 0x44, 0xd0, 0x21, 0xf2, 0x94, // 324 bytes of a gzipped FileDescriptorProto
0xa9, 0x43, 0x98, 0x59, 0x92, 0x81, 0x0e, 0x80, 0x90, 0x11, 0x4b, 0x25, 0x06, 0x37, 0xbe, 0x2a, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x41, 0x4b, 0x3b, 0x31,
0x51, 0xd3, 0x38, 0xd8, 0x2e, 0x12, 0x8f, 0xc1, 0x1b, 0x23, 0xdb, 0xa9, 0x9a, 0x56, 0x11, 0xdb, 0x10, 0xc5, 0xff, 0xfb, 0xb7, 0x2d, 0xee, 0x6c, 0x91, 0x12, 0x44, 0x82, 0xf6, 0xb0, 0xc4, 0x4b,
0x3d, 0xc7, 0x47, 0xd7, 0xe7, 0xb3, 0x0c, 0xb3, 0x8d, 0x6a, 0xcb, 0xf5, 0xbe, 0xaa, 0x05, 0xaa, 0x4f, 0x15, 0xea, 0xd9, 0x4b, 0x7b, 0xb0, 0x07, 0x15, 0x89, 0x78, 0x29, 0x78, 0x48, 0x37, 0x43,
0x9d, 0xa8, 0x17, 0xad, 0x92, 0x46, 0x92, 0xeb, 0x53, 0x97, 0xfe, 0x04, 0x10, 0x3d, 0xb0, 0x97, 0xbb, 0x74, 0xbb, 0xa9, 0x49, 0x2a, 0xf8, 0x91, 0xfc, 0x96, 0x92, 0x64, 0x4b, 0x77, 0xcb, 0xe2,
0xe2, 0x09, 0xb5, 0xe6, 0x1b, 0x24, 0x04, 0x46, 0x0d, 0xdf, 0x61, 0x1c, 0x24, 0x41, 0x1a, 0x32, 0x6d, 0xde, 0xcb, 0x30, 0x79, 0xbf, 0x61, 0xe0, 0x76, 0xa5, 0x77, 0xd9, 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 0xce, 0x75, 0x30, 0xf3, 0x34, 0x6f, 0xa8, 0xbf, 0xf2, 0x0c, 0xc9, 0x4b, 0x90, 0x73, 0x51, 0xca, 0x02, 0x35, 0x69, 0xe5,
0x58, 0x02, 0x00, 0x00, 0xa8, 0xc8, 0xaf, 0xd3, 0xb6, 0xc7, 0x7a, 0x48, 0xf6, 0x6f, 0xf2, 0x0e, 0xb1, 0x73, 0x67, 0x6b,
0xcc, 0x36, 0x64, 0x5e, 0x17, 0x7f, 0x8e, 0x1e, 0xb6, 0x3f, 0x1e, 0xc6, 0x4e, 0x07, 0x8b, 0x93,
0x0b, 0x5a, 0xf6, 0xfc, 0x61, 0xdd, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x39, 0xa8, 0x6a,
0x7f, 0x02, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ context.Context var _ context.Context
var _ grpc.ClientConn var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against. // is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4 const _ = grpc.SupportPackageIsVersion6
// GRPCServiceClient is the client API for GRPCService service. // GRPCServiceClient is the client API for GRPCService service.
// //
...@@ -277,10 +288,10 @@ type GRPCServiceClient interface { ...@@ -277,10 +288,10 @@ type GRPCServiceClient interface {
} }
type gRPCServiceClient struct { type gRPCServiceClient struct {
cc *grpc.ClientConn cc grpc.ClientConnInterface
} }
func NewGRPCServiceClient(cc *grpc.ClientConn) GRPCServiceClient { func NewGRPCServiceClient(cc grpc.ClientConnInterface) GRPCServiceClient {
return &gRPCServiceClient{cc} return &gRPCServiceClient{cc}
} }
...@@ -338,7 +349,7 @@ var _GRPCService_serviceDesc = grpc.ServiceDesc{ ...@@ -338,7 +349,7 @@ var _GRPCService_serviceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "grpcbuildermdl.proto", Metadata: "grpcbuildermdl/grpcbuildermdl.proto",
} }
// GRPCCheckClient is the client API for GRPCCheck service. // GRPCCheckClient is the client API for GRPCCheck service.
...@@ -349,10 +360,10 @@ type GRPCCheckClient interface { ...@@ -349,10 +360,10 @@ type GRPCCheckClient interface {
} }
type gRPCCheckClient struct { type gRPCCheckClient struct {
cc *grpc.ClientConn cc grpc.ClientConnInterface
} }
func NewGRPCCheckClient(cc *grpc.ClientConn) GRPCCheckClient { func NewGRPCCheckClient(cc grpc.ClientConnInterface) GRPCCheckClient {
return &gRPCCheckClient{cc} return &gRPCCheckClient{cc}
} }
...@@ -410,5 +421,5 @@ var _GRPCCheck_serviceDesc = grpc.ServiceDesc{ ...@@ -410,5 +421,5 @@ var _GRPCCheck_serviceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "grpcbuildermdl.proto", Metadata: "grpcbuildermdl/grpcbuildermdl.proto",
} }
...@@ -9,6 +9,7 @@ message GRPCMessage { ...@@ -9,6 +9,7 @@ message GRPCMessage {
bool isRestricted = 3 ; bool isRestricted = 3 ;
bool isRoleBased = 4; bool isRoleBased = 4;
string token = 5; string token = 5;
string branch = 6;
} }
......
...@@ -61,10 +61,19 @@ func (*Server) GRPCHandler(ctx context.Context, req *grpcbuildermdl.GRPCRequest) ...@@ -61,10 +61,19 @@ func (*Server) GRPCHandler(ctx context.Context, req *grpcbuildermdl.GRPCRequest)
principal.Token = req.GetGrpcMessage().GetToken() principal.Token = req.GetGrpcMessage().GetToken()
} }
result, _, _, errorCode, err := executeService( //TODO: call executeServiveBranchWise
// result, _, _, errorCode, err := executeService(
// req.GetGrpcMessage().GetName(),
// req.GetGrpcMessage().GetData(), req.GetGrpcMessage().GetIsRestricted(),
// req.GetGrpcMessage().GetIsRoleBased(), false, principal)
result, _, _, errorCode, err := executeServiceWithBranch(
req.GetGrpcMessage().GetName(), req.GetGrpcMessage().GetName(),
req.GetGrpcMessage().GetData(), req.GetGrpcMessage().GetIsRestricted(), req.GetGrpcMessage().GetBranch(),
req.GetGrpcMessage().GetData(),
req.GetGrpcMessage().GetIsRestricted(),
req.GetGrpcMessage().GetIsRoleBased(), false, principal) req.GetGrpcMessage().GetIsRoleBased(), false, principal)
e, _ := json.Marshal(result) e, _ := json.Marshal(result)
if err != nil { if err != nil {
errExecutingActivity = err.Error() errExecutingActivity = err.Error()
...@@ -103,11 +112,21 @@ func (*Server) GRPCCheck(ctx context.Context, req *grpcbuildermdl.GRPCRequest) ( ...@@ -103,11 +112,21 @@ func (*Server) GRPCCheck(ctx context.Context, req *grpcbuildermdl.GRPCRequest) (
principal.Groups = groups principal.Groups = groups
principal.UserID = userID principal.UserID = userID
principal.Token = req.GetGrpcMessage().GetToken() principal.Token = req.GetGrpcMessage().GetToken()
_, _, _, _, err := executeService(
//TODO: remove logger
loggermdl.LogError("Branch:", req.GetGrpcMessage().GetBranch())
_, _, _, _, err := executeServiceWithBranch(
req.GetGrpcMessage().GetName(), req.GetGrpcMessage().GetName(),
req.GetGrpcMessage().GetBranch(),
req.GetGrpcMessage().GetData(), req.GetGrpcMessage().GetData(),
req.GetGrpcMessage().GetIsRestricted(), req.GetGrpcMessage().GetIsRestricted(),
req.GetGrpcMessage().GetIsRoleBased(), false, principal) req.GetGrpcMessage().GetIsRoleBased(), false, principal)
// _, _, _, _, err := executeService(
// req.GetGrpcMessage().GetName(),
// req.GetGrpcMessage().GetData(),
// req.GetGrpcMessage().GetIsRestricted(),
// req.GetGrpcMessage().GetIsRoleBased(), false, principal)
res := &grpcbuildermdl.GRPCResponse{ res := &grpcbuildermdl.GRPCResponse{
Data: "Response from GRPC Check service", Data: "Response from GRPC Check service",
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment