Record event & check user relation permission APis

This commit is contained in:
LittleSheep 2024-07-15 20:04:03 +08:00
parent ad83100677
commit 4e96bb2cd5
9 changed files with 694 additions and 49 deletions

View File

@ -3,10 +3,11 @@ package grpc
import ( import (
"context" "context"
"fmt" "fmt"
"time"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper" "git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/internal/directory" "git.solsynth.dev/hydrogen/dealer/pkg/internal/directory"
"git.solsynth.dev/hydrogen/dealer/pkg/proto" "git.solsynth.dev/hydrogen/dealer/pkg/proto"
"time"
) )
func (v *Server) Authenticate(ctx context.Context, request *proto.AuthRequest) (*proto.AuthReply, error) { func (v *Server) Authenticate(ctx context.Context, request *proto.AuthRequest) (*proto.AuthReply, error) {
@ -27,10 +28,10 @@ func (v *Server) Authenticate(ctx context.Context, request *proto.AuthRequest) (
return out, err return out, err
} }
func (v *Server) EnsurePermGranted(ctx context.Context, request *proto.CheckPermRequest) (*proto.CheckPermReply, error) { func (v *Server) EnsurePermGranted(ctx context.Context, request *proto.CheckPermRequest) (*proto.CheckPermResponse, error) {
instance := directory.GetServiceInstanceByType(hyper.ServiceTypeAuthProvider) instance := directory.GetServiceInstanceByType(hyper.ServiceTypeAuthProvider)
if instance == nil { if instance == nil {
return &proto.CheckPermReply{}, fmt.Errorf("no available service %s found", hyper.ServiceTypeAuthProvider) return &proto.CheckPermResponse{}, fmt.Errorf("no available service %s found", hyper.ServiceTypeAuthProvider)
} }
conn, err := instance.GetGrpcConn() conn, err := instance.GetGrpcConn()
@ -44,3 +45,21 @@ func (v *Server) EnsurePermGranted(ctx context.Context, request *proto.CheckPerm
out, err := proto.NewAuthClient(conn).EnsurePermGranted(ctx, request) out, err := proto.NewAuthClient(conn).EnsurePermGranted(ctx, request)
return out, err return out, err
} }
func (v *Server) EnsureUserPermGranted(ctx context.Context, request *proto.CheckUserPermRequest) (*proto.CheckUserPermResponse, error) {
instance := directory.GetServiceInstance(hyper.ServiceTypeAuthProvider)
if instance == nil {
return &proto.CheckUserPermResponse{}, fmt.Errorf("no available service %s found", hyper.ServiceTypeAuthProvider)
}
conn, err := instance.GetGrpcConn()
if err != nil {
return nil, fmt.Errorf("service is down: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
out, err := proto.NewAuthClient(conn).EnsureUserPermGranted(ctx, request)
return out, err
}

View File

@ -0,0 +1,29 @@
package grpc
import (
"context"
"fmt"
"time"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/internal/directory"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
)
func (v *Server) RecordEvent(ctx context.Context, request *proto.RecordEventRequest) (*proto.RecordEventResponse, error) {
instance := directory.GetServiceInstance(hyper.ServiceTypeAuthProvider)
if instance == nil {
return &proto.RecordEventResponse{}, fmt.Errorf("no available service %s found", hyper.ServiceTypeAuthProvider)
}
conn, err := instance.GetGrpcConn()
if err != nil {
return nil, fmt.Errorf("service is down: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
out, err := proto.NewEventRecorderClient(conn).RecordEvent(ctx, request)
return out, err
}

View File

@ -1,9 +1,10 @@
package grpc package grpc
import ( import (
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"net" "net"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -15,6 +16,7 @@ import (
type Server struct { type Server struct {
proto.UnimplementedServiceDirectoryServer proto.UnimplementedServiceDirectoryServer
proto.UnimplementedStreamControllerServer proto.UnimplementedStreamControllerServer
proto.UnimplementedEventRecorderServer
proto.UnimplementedAuthServer proto.UnimplementedAuthServer
srv *grpc.Server srv *grpc.Server
@ -27,6 +29,7 @@ func NewServer() *Server {
proto.RegisterServiceDirectoryServer(server.srv, server) proto.RegisterServiceDirectoryServer(server.srv, server)
proto.RegisterStreamControllerServer(server.srv, server) proto.RegisterStreamControllerServer(server.srv, server)
proto.RegisterEventRecorderServer(server.srv, server)
proto.RegisterAuthServer(server.srv, server) proto.RegisterAuthServer(server.srv, server)
health.RegisterHealthServer(server.srv, server) health.RegisterHealthServer(server.srv, server)

View File

@ -367,7 +367,7 @@ func (x *CheckPermRequest) GetValue() []byte {
return nil return nil
} }
type CheckPermReply struct { type CheckPermResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@ -375,8 +375,8 @@ type CheckPermReply struct {
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"` IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
} }
func (x *CheckPermReply) Reset() { func (x *CheckPermResponse) Reset() {
*x = CheckPermReply{} *x = CheckPermResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[5] mi := &file_auth_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -384,13 +384,13 @@ func (x *CheckPermReply) Reset() {
} }
} }
func (x *CheckPermReply) String() string { func (x *CheckPermResponse) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*CheckPermReply) ProtoMessage() {} func (*CheckPermResponse) ProtoMessage() {}
func (x *CheckPermReply) ProtoReflect() protoreflect.Message { func (x *CheckPermResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[5] mi := &file_auth_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -402,12 +402,130 @@ func (x *CheckPermReply) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use CheckPermReply.ProtoReflect.Descriptor instead. // Deprecated: Use CheckPermResponse.ProtoReflect.Descriptor instead.
func (*CheckPermReply) Descriptor() ([]byte, []int) { func (*CheckPermResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{5} return file_auth_proto_rawDescGZIP(), []int{5}
} }
func (x *CheckPermReply) GetIsValid() bool { func (x *CheckPermResponse) GetIsValid() bool {
if x != nil {
return x.IsValid
}
return false
}
type CheckUserPermRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
OtherId uint64 `protobuf:"varint,2,opt,name=other_id,json=otherId,proto3" json:"other_id,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *CheckUserPermRequest) Reset() {
*x = CheckUserPermRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CheckUserPermRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CheckUserPermRequest) ProtoMessage() {}
func (x *CheckUserPermRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_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 CheckUserPermRequest.ProtoReflect.Descriptor instead.
func (*CheckUserPermRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{6}
}
func (x *CheckUserPermRequest) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *CheckUserPermRequest) GetOtherId() uint64 {
if x != nil {
return x.OtherId
}
return 0
}
func (x *CheckUserPermRequest) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *CheckUserPermRequest) GetValue() []byte {
if x != nil {
return x.Value
}
return nil
}
type CheckUserPermResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
}
func (x *CheckUserPermResponse) Reset() {
*x = CheckUserPermResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CheckUserPermResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CheckUserPermResponse) ProtoMessage() {}
func (x *CheckUserPermResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_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 CheckUserPermResponse.ProtoReflect.Descriptor instead.
func (*CheckUserPermResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{7}
}
func (x *CheckUserPermResponse) GetIsValid() bool {
if x != nil { if x != nil {
return x.IsValid return x.IsValid
} }
@ -463,20 +581,36 @@ var file_auth_proto_rawDesc = []byte{
0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74,
0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2b, 0x0a, 0x0e, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2e, 0x0a, 0x11,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x19, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20,
0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x32, 0x85, 0x01, 0x0a, 0x04, 0x41, 0x75, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x22, 0x72, 0x0a, 0x14,
0x74, 0x68, 0x12, 0x36, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71,
0x74, 0x65, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a,
0x75, 0x74, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x11, 0x45, 0x6e, 0x08, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
0x73, 0x75, 0x72, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x64, 0x12, 0x07, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61,
0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x22, 0x32, 0x0a, 0x15, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72,
0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f,
0x6f, 0x74, 0x6f, 0x33, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56,
0x61, 0x6c, 0x69, 0x64, 0x32, 0xde, 0x01, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x36, 0x0a,
0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x12, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x11, 0x45, 0x6e, 0x73, 0x75, 0x72, 0x65, 0x50,
0x65, 0x72, 0x6d, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x54, 0x0a, 0x15, 0x45, 0x6e, 0x73, 0x75, 0x72, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72,
0x6d, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x64, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -491,24 +625,28 @@ func file_auth_proto_rawDescGZIP() []byte {
return file_auth_proto_rawDescData return file_auth_proto_rawDescData
} }
var file_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_auth_proto_goTypes = []any{ var file_auth_proto_goTypes = []any{
(*UserInfo)(nil), // 0: proto.UserInfo (*UserInfo)(nil), // 0: proto.UserInfo
(*AuthInfo)(nil), // 1: proto.AuthInfo (*AuthInfo)(nil), // 1: proto.AuthInfo
(*AuthRequest)(nil), // 2: proto.AuthRequest (*AuthRequest)(nil), // 2: proto.AuthRequest
(*AuthReply)(nil), // 3: proto.AuthReply (*AuthReply)(nil), // 3: proto.AuthReply
(*CheckPermRequest)(nil), // 4: proto.CheckPermRequest (*CheckPermRequest)(nil), // 4: proto.CheckPermRequest
(*CheckPermReply)(nil), // 5: proto.CheckPermReply (*CheckPermResponse)(nil), // 5: proto.CheckPermResponse
(*CheckUserPermRequest)(nil), // 6: proto.CheckUserPermRequest
(*CheckUserPermResponse)(nil), // 7: proto.CheckUserPermResponse
} }
var file_auth_proto_depIdxs = []int32{ var file_auth_proto_depIdxs = []int32{
0, // 0: proto.AuthInfo.info:type_name -> proto.UserInfo 0, // 0: proto.AuthInfo.info:type_name -> proto.UserInfo
1, // 1: proto.AuthReply.info:type_name -> proto.AuthInfo 1, // 1: proto.AuthReply.info:type_name -> proto.AuthInfo
2, // 2: proto.Auth.Authenticate:input_type -> proto.AuthRequest 2, // 2: proto.Auth.Authenticate:input_type -> proto.AuthRequest
4, // 3: proto.Auth.EnsurePermGranted:input_type -> proto.CheckPermRequest 4, // 3: proto.Auth.EnsurePermGranted:input_type -> proto.CheckPermRequest
3, // 4: proto.Auth.Authenticate:output_type -> proto.AuthReply 6, // 4: proto.Auth.EnsureUserPermGranted:input_type -> proto.CheckUserPermRequest
5, // 5: proto.Auth.EnsurePermGranted:output_type -> proto.CheckPermReply 3, // 5: proto.Auth.Authenticate:output_type -> proto.AuthReply
4, // [4:6] is the sub-list for method output_type 5, // 6: proto.Auth.EnsurePermGranted:output_type -> proto.CheckPermResponse
2, // [2:4] is the sub-list for method input_type 7, // 7: proto.Auth.EnsureUserPermGranted:output_type -> proto.CheckUserPermResponse
5, // [5:8] is the sub-list for method output_type
2, // [2:5] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee 2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name 0, // [0:2] is the sub-list for field type_name
@ -581,7 +719,31 @@ func file_auth_proto_init() {
} }
} }
file_auth_proto_msgTypes[5].Exporter = func(v any, i int) any { file_auth_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*CheckPermReply); i { switch v := v.(*CheckPermResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*CheckUserPermRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[7].Exporter = func(v any, i int) any {
switch v := v.(*CheckUserPermResponse); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -603,7 +765,7 @@ func file_auth_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_auth_proto_rawDesc, RawDescriptor: file_auth_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 8,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -6,7 +6,8 @@ package proto;
service Auth { service Auth {
rpc Authenticate(AuthRequest) returns (AuthReply) {} rpc Authenticate(AuthRequest) returns (AuthReply) {}
rpc EnsurePermGranted(CheckPermRequest) returns (CheckPermReply) {} rpc EnsurePermGranted(CheckPermRequest) returns (CheckPermResponse) {}
rpc EnsureUserPermGranted(CheckUserPermRequest) returns (CheckUserPermResponse) {}
} }
message UserInfo { message UserInfo {
@ -43,6 +44,17 @@ message CheckPermRequest {
bytes value = 3; bytes value = 3;
} }
message CheckPermReply { message CheckPermResponse {
bool is_valid = 1;
}
message CheckUserPermRequest {
uint64 user_id = 1;
uint64 other_id = 2;
string key = 3;
bytes value = 4;
}
message CheckUserPermResponse {
bool is_valid = 1; bool is_valid = 1;
} }

View File

@ -19,8 +19,9 @@ import (
const _ = grpc.SupportPackageIsVersion8 const _ = grpc.SupportPackageIsVersion8
const ( const (
Auth_Authenticate_FullMethodName = "/proto.Auth/Authenticate" Auth_Authenticate_FullMethodName = "/proto.Auth/Authenticate"
Auth_EnsurePermGranted_FullMethodName = "/proto.Auth/EnsurePermGranted" Auth_EnsurePermGranted_FullMethodName = "/proto.Auth/EnsurePermGranted"
Auth_EnsureUserPermGranted_FullMethodName = "/proto.Auth/EnsureUserPermGranted"
) )
// AuthClient is the client API for Auth service. // AuthClient is the client API for Auth service.
@ -28,7 +29,8 @@ const (
// 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. // 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 AuthClient interface { type AuthClient interface {
Authenticate(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthReply, error) Authenticate(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthReply, error)
EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermReply, error) EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermResponse, error)
EnsureUserPermGranted(ctx context.Context, in *CheckUserPermRequest, opts ...grpc.CallOption) (*CheckUserPermResponse, error)
} }
type authClient struct { type authClient struct {
@ -49,9 +51,9 @@ func (c *authClient) Authenticate(ctx context.Context, in *AuthRequest, opts ...
return out, nil return out, nil
} }
func (c *authClient) EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermReply, error) { func (c *authClient) EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CheckPermReply) out := new(CheckPermResponse)
err := c.cc.Invoke(ctx, Auth_EnsurePermGranted_FullMethodName, in, out, cOpts...) err := c.cc.Invoke(ctx, Auth_EnsurePermGranted_FullMethodName, in, out, cOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -59,12 +61,23 @@ func (c *authClient) EnsurePermGranted(ctx context.Context, in *CheckPermRequest
return out, nil return out, nil
} }
func (c *authClient) EnsureUserPermGranted(ctx context.Context, in *CheckUserPermRequest, opts ...grpc.CallOption) (*CheckUserPermResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CheckUserPermResponse)
err := c.cc.Invoke(ctx, Auth_EnsureUserPermGranted_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthServer is the server API for Auth service. // AuthServer is the server API for Auth service.
// All implementations must embed UnimplementedAuthServer // All implementations must embed UnimplementedAuthServer
// for forward compatibility // for forward compatibility
type AuthServer interface { type AuthServer interface {
Authenticate(context.Context, *AuthRequest) (*AuthReply, error) Authenticate(context.Context, *AuthRequest) (*AuthReply, error)
EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermReply, error) EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermResponse, error)
EnsureUserPermGranted(context.Context, *CheckUserPermRequest) (*CheckUserPermResponse, error)
mustEmbedUnimplementedAuthServer() mustEmbedUnimplementedAuthServer()
} }
@ -75,9 +88,12 @@ type UnimplementedAuthServer struct {
func (UnimplementedAuthServer) Authenticate(context.Context, *AuthRequest) (*AuthReply, error) { func (UnimplementedAuthServer) Authenticate(context.Context, *AuthRequest) (*AuthReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented")
} }
func (UnimplementedAuthServer) EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermReply, error) { func (UnimplementedAuthServer) EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method EnsurePermGranted not implemented") return nil, status.Errorf(codes.Unimplemented, "method EnsurePermGranted not implemented")
} }
func (UnimplementedAuthServer) EnsureUserPermGranted(context.Context, *CheckUserPermRequest) (*CheckUserPermResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method EnsureUserPermGranted not implemented")
}
func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {} func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {}
// UnsafeAuthServer may be embedded to opt out of forward compatibility for this service. // UnsafeAuthServer may be embedded to opt out of forward compatibility for this service.
@ -127,6 +143,24 @@ func _Auth_EnsurePermGranted_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Auth_EnsureUserPermGranted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CheckUserPermRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServer).EnsureUserPermGranted(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Auth_EnsureUserPermGranted_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServer).EnsureUserPermGranted(ctx, req.(*CheckUserPermRequest))
}
return interceptor(ctx, in, info, handler)
}
// Auth_ServiceDesc is the grpc.ServiceDesc for Auth service. // Auth_ServiceDesc is the grpc.ServiceDesc for Auth service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -142,6 +176,10 @@ var Auth_ServiceDesc = grpc.ServiceDesc{
MethodName: "EnsurePermGranted", MethodName: "EnsurePermGranted",
Handler: _Auth_EnsurePermGranted_Handler, Handler: _Auth_EnsurePermGranted_Handler,
}, },
{
MethodName: "EnsureUserPermGranted",
Handler: _Auth_EnsureUserPermGranted_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "auth.proto", Metadata: "auth.proto",

251
pkg/proto/record.pb.go Normal file
View File

@ -0,0 +1,251 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v5.27.1
// source: record.proto
package proto
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 RecordEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"`
Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"`
Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"`
UserAgent string `protobuf:"bytes,5,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
}
func (x *RecordEventRequest) Reset() {
*x = RecordEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_record_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RecordEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordEventRequest) ProtoMessage() {}
func (x *RecordEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_record_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 RecordEventRequest.ProtoReflect.Descriptor instead.
func (*RecordEventRequest) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{0}
}
func (x *RecordEventRequest) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *RecordEventRequest) GetAction() string {
if x != nil {
return x.Action
}
return ""
}
func (x *RecordEventRequest) GetTarget() string {
if x != nil {
return x.Target
}
return ""
}
func (x *RecordEventRequest) GetIp() string {
if x != nil {
return x.Ip
}
return ""
}
func (x *RecordEventRequest) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
type RecordEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
}
func (x *RecordEventResponse) Reset() {
*x = RecordEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_record_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RecordEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordEventResponse) ProtoMessage() {}
func (x *RecordEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_record_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 RecordEventResponse.ProtoReflect.Descriptor instead.
func (*RecordEventResponse) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{1}
}
func (x *RecordEventResponse) GetIsSuccess() bool {
if x != nil {
return x.IsSuccess
}
return false
}
var File_record_proto protoreflect.FileDescriptor
var file_record_proto_rawDesc = []byte{
0x0a, 0x0c, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07,
0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75,
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a,
0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x67,
0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41,
0x67, 0x65, 0x6e, 0x74, 0x22, 0x34, 0x0a, 0x13, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69,
0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32, 0x57, 0x0a, 0x0d, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x0b, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_record_proto_rawDescOnce sync.Once
file_record_proto_rawDescData = file_record_proto_rawDesc
)
func file_record_proto_rawDescGZIP() []byte {
file_record_proto_rawDescOnce.Do(func() {
file_record_proto_rawDescData = protoimpl.X.CompressGZIP(file_record_proto_rawDescData)
})
return file_record_proto_rawDescData
}
var file_record_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_record_proto_goTypes = []any{
(*RecordEventRequest)(nil), // 0: proto.RecordEventRequest
(*RecordEventResponse)(nil), // 1: proto.RecordEventResponse
}
var file_record_proto_depIdxs = []int32{
0, // 0: proto.EventRecorder.RecordEvent:input_type -> proto.RecordEventRequest
1, // 1: proto.EventRecorder.RecordEvent:output_type -> proto.RecordEventResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_record_proto_init() }
func file_record_proto_init() {
if File_record_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_record_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*RecordEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_record_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*RecordEventResponse); 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_record_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_record_proto_goTypes,
DependencyIndexes: file_record_proto_depIdxs,
MessageInfos: file_record_proto_msgTypes,
}.Build()
File_record_proto = out.File
file_record_proto_rawDesc = nil
file_record_proto_goTypes = nil
file_record_proto_depIdxs = nil
}

21
pkg/proto/record.proto Normal file
View File

@ -0,0 +1,21 @@
syntax = "proto3";
option go_package = ".;proto";
package proto;
service EventRecorder {
rpc RecordEvent(RecordEventRequest) returns (RecordEventResponse) {}
}
message RecordEventRequest {
uint64 user_id = 1;
string action = 2;
string target = 3;
string ip = 4;
string user_agent = 5;
}
message RecordEventResponse {
bool is_success = 1;
}

110
pkg/proto/record_grpc.pb.go Normal file
View File

@ -0,0 +1,110 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc v5.27.1
// source: record.proto
package proto
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.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
EventRecorder_RecordEvent_FullMethodName = "/proto.EventRecorder/RecordEvent"
)
// EventRecorderClient is the client API for EventRecorder 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 EventRecorderClient interface {
RecordEvent(ctx context.Context, in *RecordEventRequest, opts ...grpc.CallOption) (*RecordEventResponse, error)
}
type eventRecorderClient struct {
cc grpc.ClientConnInterface
}
func NewEventRecorderClient(cc grpc.ClientConnInterface) EventRecorderClient {
return &eventRecorderClient{cc}
}
func (c *eventRecorderClient) RecordEvent(ctx context.Context, in *RecordEventRequest, opts ...grpc.CallOption) (*RecordEventResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RecordEventResponse)
err := c.cc.Invoke(ctx, EventRecorder_RecordEvent_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// EventRecorderServer is the server API for EventRecorder service.
// All implementations must embed UnimplementedEventRecorderServer
// for forward compatibility
type EventRecorderServer interface {
RecordEvent(context.Context, *RecordEventRequest) (*RecordEventResponse, error)
mustEmbedUnimplementedEventRecorderServer()
}
// UnimplementedEventRecorderServer must be embedded to have forward compatible implementations.
type UnimplementedEventRecorderServer struct {
}
func (UnimplementedEventRecorderServer) RecordEvent(context.Context, *RecordEventRequest) (*RecordEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RecordEvent not implemented")
}
func (UnimplementedEventRecorderServer) mustEmbedUnimplementedEventRecorderServer() {}
// UnsafeEventRecorderServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to EventRecorderServer will
// result in compilation errors.
type UnsafeEventRecorderServer interface {
mustEmbedUnimplementedEventRecorderServer()
}
func RegisterEventRecorderServer(s grpc.ServiceRegistrar, srv EventRecorderServer) {
s.RegisterService(&EventRecorder_ServiceDesc, srv)
}
func _EventRecorder_RecordEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RecordEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EventRecorderServer).RecordEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: EventRecorder_RecordEvent_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EventRecorderServer).RecordEvent(ctx, req.(*RecordEventRequest))
}
return interceptor(ctx, in, info, handler)
}
// EventRecorder_ServiceDesc is the grpc.ServiceDesc for EventRecorder service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var EventRecorder_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.EventRecorder",
HandlerType: (*EventRecorderServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "RecordEvent",
Handler: _EventRecorder_RecordEvent_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "record.proto",
}