diff options
Diffstat (limited to 'pkg/rpc')
| -rw-r--r-- | pkg/rpc/ability.pb.go | 194 | ||||
| -rw-r--r-- | pkg/rpc/ability_grpc.pb.go | 121 |
2 files changed, 315 insertions, 0 deletions
diff --git a/pkg/rpc/ability.pb.go b/pkg/rpc/ability.pb.go new file mode 100644 index 00000000..48dd0b24 --- /dev/null +++ b/pkg/rpc/ability.pb.go @@ -0,0 +1,194 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v3.19.6 +// source: ability.proto + +package rpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 AllowRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"` + Permission string `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Resource string `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AllowRequest) Reset() { + *x = AllowRequest{} + mi := &file_ability_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AllowRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowRequest) ProtoMessage() {} + +func (x *AllowRequest) ProtoReflect() protoreflect.Message { + mi := &file_ability_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AllowRequest.ProtoReflect.Descriptor instead. +func (*AllowRequest) Descriptor() ([]byte, []int) { + return file_ability_proto_rawDescGZIP(), []int{0} +} + +func (x *AllowRequest) GetSubject() string { + if x != nil { + return x.Subject + } + return "" +} + +func (x *AllowRequest) GetPermission() string { + if x != nil { + return x.Permission + } + return "" +} + +func (x *AllowRequest) GetResource() string { + if x != nil { + return x.Resource + } + return "" +} + +type AllowReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Result bool `protobuf:"varint,1,opt,name=result,proto3" json:"result,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AllowReply) Reset() { + *x = AllowReply{} + mi := &file_ability_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AllowReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowReply) ProtoMessage() {} + +func (x *AllowReply) ProtoReflect() protoreflect.Message { + mi := &file_ability_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AllowReply.ProtoReflect.Descriptor instead. +func (*AllowReply) Descriptor() ([]byte, []int) { + return file_ability_proto_rawDescGZIP(), []int{1} +} + +func (x *AllowReply) GetResult() bool { + if x != nil { + return x.Result + } + return false +} + +var File_ability_proto protoreflect.FileDescriptor + +const file_ability_proto_rawDesc = "" + + "\n" + + "\rability.proto\x12\tauthx.rpc\"d\n" + + "\fAllowRequest\x12\x18\n" + + "\asubject\x18\x01 \x01(\tR\asubject\x12\x1e\n" + + "\n" + + "permission\x18\x02 \x01(\tR\n" + + "permission\x12\x1a\n" + + "\bresource\x18\x03 \x01(\tR\bresource\"$\n" + + "\n" + + "AllowReply\x12\x16\n" + + "\x06result\x18\x01 \x01(\bR\x06result2F\n" + + "\aAbility\x12;\n" + + "\aAllowed\x12\x17.authx.rpc.AllowRequest\x1a\x15.authx.rpc.AllowReply\"\x00B!Z\x1fgitlab.com/mokhax/spike/pkg/rpcb\x06proto3" + +var ( + file_ability_proto_rawDescOnce sync.Once + file_ability_proto_rawDescData []byte +) + +func file_ability_proto_rawDescGZIP() []byte { + file_ability_proto_rawDescOnce.Do(func() { + file_ability_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_ability_proto_rawDesc), len(file_ability_proto_rawDesc))) + }) + return file_ability_proto_rawDescData +} + +var file_ability_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_ability_proto_goTypes = []any{ + (*AllowRequest)(nil), // 0: authx.rpc.AllowRequest + (*AllowReply)(nil), // 1: authx.rpc.AllowReply +} +var file_ability_proto_depIdxs = []int32{ + 0, // 0: authx.rpc.Ability.Allowed:input_type -> authx.rpc.AllowRequest + 1, // 1: authx.rpc.Ability.Allowed:output_type -> authx.rpc.AllowReply + 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_ability_proto_init() } +func file_ability_proto_init() { + if File_ability_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_ability_proto_rawDesc), len(file_ability_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_ability_proto_goTypes, + DependencyIndexes: file_ability_proto_depIdxs, + MessageInfos: file_ability_proto_msgTypes, + }.Build() + File_ability_proto = out.File + file_ability_proto_goTypes = nil + file_ability_proto_depIdxs = nil +} diff --git a/pkg/rpc/ability_grpc.pb.go b/pkg/rpc/ability_grpc.pb.go new file mode 100644 index 00000000..4d74cc41 --- /dev/null +++ b/pkg/rpc/ability_grpc.pb.go @@ -0,0 +1,121 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.19.6 +// source: ability.proto + +package rpc + +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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Ability_Allowed_FullMethodName = "/authx.rpc.Ability/Allowed" +) + +// AbilityClient is the client API for Ability 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 AbilityClient interface { + Allowed(ctx context.Context, in *AllowRequest, opts ...grpc.CallOption) (*AllowReply, error) +} + +type abilityClient struct { + cc grpc.ClientConnInterface +} + +func NewAbilityClient(cc grpc.ClientConnInterface) AbilityClient { + return &abilityClient{cc} +} + +func (c *abilityClient) Allowed(ctx context.Context, in *AllowRequest, opts ...grpc.CallOption) (*AllowReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AllowReply) + err := c.cc.Invoke(ctx, Ability_Allowed_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AbilityServer is the server API for Ability service. +// All implementations must embed UnimplementedAbilityServer +// for forward compatibility. +type AbilityServer interface { + Allowed(context.Context, *AllowRequest) (*AllowReply, error) + mustEmbedUnimplementedAbilityServer() +} + +// UnimplementedAbilityServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAbilityServer struct{} + +func (UnimplementedAbilityServer) Allowed(context.Context, *AllowRequest) (*AllowReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Allowed not implemented") +} +func (UnimplementedAbilityServer) mustEmbedUnimplementedAbilityServer() {} +func (UnimplementedAbilityServer) testEmbeddedByValue() {} + +// UnsafeAbilityServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AbilityServer will +// result in compilation errors. +type UnsafeAbilityServer interface { + mustEmbedUnimplementedAbilityServer() +} + +func RegisterAbilityServer(s grpc.ServiceRegistrar, srv AbilityServer) { + // If the following call pancis, it indicates UnimplementedAbilityServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Ability_ServiceDesc, srv) +} + +func _Ability_Allowed_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AllowRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AbilityServer).Allowed(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Ability_Allowed_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AbilityServer).Allowed(ctx, req.(*AllowRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Ability_ServiceDesc is the grpc.ServiceDesc for Ability service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Ability_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "authx.rpc.Ability", + HandlerType: (*AbilityServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Allowed", + Handler: _Ability_Allowed_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ability.proto", +} |
