From 0912f5496d1f7b319f35fd4417550c7681a38dbb Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 25 Apr 2024 14:23:22 +0300 Subject: [PATCH] add proto --- docs/proto/promo.proto | 7 +- internal/proto/codeword/promo.pb.go | 296 +++++++++++++++++++++++ internal/proto/codeword/promo_grpc.pb.go | 101 ++++++++ 3 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 internal/proto/codeword/promo.pb.go create mode 100644 internal/proto/codeword/promo_grpc.pb.go diff --git a/docs/proto/promo.proto b/docs/proto/promo.proto index 45a796a..052aca2 100644 --- a/docs/proto/promo.proto +++ b/docs/proto/promo.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package codeword; +option go_package = "./codeword_rpc"; + message Time { int64 from = 1; int64 to = 2; @@ -12,5 +14,8 @@ service PromoCodeService { } message PromoActivationResp { - map response = 1; + message Activations { + repeated string values = 1; + } + map response = 1; } diff --git a/internal/proto/codeword/promo.pb.go b/internal/proto/codeword/promo.pb.go new file mode 100644 index 0000000..4262b0f --- /dev/null +++ b/internal/proto/codeword/promo.pb.go @@ -0,0 +1,296 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: promo.proto + +package codeword_rpc + +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 Time struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + From int64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` + To int64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (x *Time) Reset() { + *x = Time{} + if protoimpl.UnsafeEnabled { + mi := &file_promo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Time) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Time) ProtoMessage() {} + +func (x *Time) ProtoReflect() protoreflect.Message { + mi := &file_promo_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 Time.ProtoReflect.Descriptor instead. +func (*Time) Descriptor() ([]byte, []int) { + return file_promo_proto_rawDescGZIP(), []int{0} +} + +func (x *Time) GetFrom() int64 { + if x != nil { + return x.From + } + return 0 +} + +func (x *Time) GetTo() int64 { + if x != nil { + return x.To + } + return 0 +} + +type PromoActivationResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Response map[string]*PromoActivationResp_Activations `protobuf:"bytes,1,rep,name=response,proto3" json:"response,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *PromoActivationResp) Reset() { + *x = PromoActivationResp{} + if protoimpl.UnsafeEnabled { + mi := &file_promo_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PromoActivationResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PromoActivationResp) ProtoMessage() {} + +func (x *PromoActivationResp) ProtoReflect() protoreflect.Message { + mi := &file_promo_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 PromoActivationResp.ProtoReflect.Descriptor instead. +func (*PromoActivationResp) Descriptor() ([]byte, []int) { + return file_promo_proto_rawDescGZIP(), []int{1} +} + +func (x *PromoActivationResp) GetResponse() map[string]*PromoActivationResp_Activations { + if x != nil { + return x.Response + } + return nil +} + +type PromoActivationResp_Activations struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` +} + +func (x *PromoActivationResp_Activations) Reset() { + *x = PromoActivationResp_Activations{} + if protoimpl.UnsafeEnabled { + mi := &file_promo_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PromoActivationResp_Activations) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PromoActivationResp_Activations) ProtoMessage() {} + +func (x *PromoActivationResp_Activations) ProtoReflect() protoreflect.Message { + mi := &file_promo_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 PromoActivationResp_Activations.ProtoReflect.Descriptor instead. +func (*PromoActivationResp_Activations) Descriptor() ([]byte, []int) { + return file_promo_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *PromoActivationResp_Activations) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + +var File_promo_proto protoreflect.FileDescriptor + +var file_promo_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x63, + 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x2a, 0x0a, 0x04, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x66, + 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x02, 0x74, 0x6f, 0x22, 0xed, 0x01, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x47, 0x0a, 0x08, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, + 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x25, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0x66, 0x0a, 0x0d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x3f, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, + 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x32, 0x5b, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x43, 0x6f, 0x64, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x41, 0x6c, + 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x0e, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x1a, 0x1d, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x2e, 0x50, 0x72, 0x6f, + 0x6d, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x72, + 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_promo_proto_rawDescOnce sync.Once + file_promo_proto_rawDescData = file_promo_proto_rawDesc +) + +func file_promo_proto_rawDescGZIP() []byte { + file_promo_proto_rawDescOnce.Do(func() { + file_promo_proto_rawDescData = protoimpl.X.CompressGZIP(file_promo_proto_rawDescData) + }) + return file_promo_proto_rawDescData +} + +var file_promo_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_promo_proto_goTypes = []interface{}{ + (*Time)(nil), // 0: codeword.Time + (*PromoActivationResp)(nil), // 1: codeword.PromoActivationResp + (*PromoActivationResp_Activations)(nil), // 2: codeword.PromoActivationResp.Activations + nil, // 3: codeword.PromoActivationResp.ResponseEntry +} +var file_promo_proto_depIdxs = []int32{ + 3, // 0: codeword.PromoActivationResp.response:type_name -> codeword.PromoActivationResp.ResponseEntry + 2, // 1: codeword.PromoActivationResp.ResponseEntry.value:type_name -> codeword.PromoActivationResp.Activations + 0, // 2: codeword.PromoCodeService.GetAllPromoActivations:input_type -> codeword.Time + 1, // 3: codeword.PromoCodeService.GetAllPromoActivations:output_type -> codeword.PromoActivationResp + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] 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 extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_promo_proto_init() } +func file_promo_proto_init() { + if File_promo_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_promo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Time); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_promo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PromoActivationResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_promo_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PromoActivationResp_Activations); 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_promo_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_promo_proto_goTypes, + DependencyIndexes: file_promo_proto_depIdxs, + MessageInfos: file_promo_proto_msgTypes, + }.Build() + File_promo_proto = out.File + file_promo_proto_rawDesc = nil + file_promo_proto_goTypes = nil + file_promo_proto_depIdxs = nil +} diff --git a/internal/proto/codeword/promo_grpc.pb.go b/internal/proto/codeword/promo_grpc.pb.go new file mode 100644 index 0000000..9e225c9 --- /dev/null +++ b/internal/proto/codeword/promo_grpc.pb.go @@ -0,0 +1,101 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package codeword_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.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// PromoCodeServiceClient is the client API for PromoCodeService 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 PromoCodeServiceClient interface { + GetAllPromoActivations(ctx context.Context, in *Time, opts ...grpc.CallOption) (*PromoActivationResp, error) +} + +type promoCodeServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPromoCodeServiceClient(cc grpc.ClientConnInterface) PromoCodeServiceClient { + return &promoCodeServiceClient{cc} +} + +func (c *promoCodeServiceClient) GetAllPromoActivations(ctx context.Context, in *Time, opts ...grpc.CallOption) (*PromoActivationResp, error) { + out := new(PromoActivationResp) + err := c.cc.Invoke(ctx, "/codeword.PromoCodeService/GetAllPromoActivations", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PromoCodeServiceServer is the server API for PromoCodeService service. +// All implementations must embed UnimplementedPromoCodeServiceServer +// for forward compatibility +type PromoCodeServiceServer interface { + GetAllPromoActivations(context.Context, *Time) (*PromoActivationResp, error) + mustEmbedUnimplementedPromoCodeServiceServer() +} + +// UnimplementedPromoCodeServiceServer must be embedded to have forward compatible implementations. +type UnimplementedPromoCodeServiceServer struct { +} + +func (UnimplementedPromoCodeServiceServer) GetAllPromoActivations(context.Context, *Time) (*PromoActivationResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAllPromoActivations not implemented") +} +func (UnimplementedPromoCodeServiceServer) mustEmbedUnimplementedPromoCodeServiceServer() {} + +// UnsafePromoCodeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PromoCodeServiceServer will +// result in compilation errors. +type UnsafePromoCodeServiceServer interface { + mustEmbedUnimplementedPromoCodeServiceServer() +} + +func RegisterPromoCodeServiceServer(s grpc.ServiceRegistrar, srv PromoCodeServiceServer) { + s.RegisterService(&PromoCodeService_ServiceDesc, srv) +} + +func _PromoCodeService_GetAllPromoActivations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Time) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PromoCodeServiceServer).GetAllPromoActivations(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/codeword.PromoCodeService/GetAllPromoActivations", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PromoCodeServiceServer).GetAllPromoActivations(ctx, req.(*Time)) + } + return interceptor(ctx, in, info, handler) +} + +// PromoCodeService_ServiceDesc is the grpc.ServiceDesc for PromoCodeService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PromoCodeService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "codeword.PromoCodeService", + HandlerType: (*PromoCodeServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetAllPromoActivations", + Handler: _PromoCodeService_GetAllPromoActivations_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "promo.proto", +}