From 74e6c3f3dedfc6e88800b630aa5d60c7cc618899 Mon Sep 17 00:00:00 2001 From: guoshijiang Date: Fri, 15 Mar 2024 20:57:27 +0800 Subject: [PATCH] online fix --- airdrop/airdrop_server.py | 6 +-- services/airdrop_client.py | 6 ++- services/savour_rpc/airdrop_grpc.py | 40 +++++++++++++++++++ services/savour_rpc/airdrop_pb2.py | 53 ++++++++++++------------- services/savour_rpc/airdrop_pb2_grpc.py | 20 +++++----- services/savour_rpc/common_pb2.py | 4 +- 6 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 services/savour_rpc/airdrop_grpc.py diff --git a/airdrop/airdrop_server.py b/airdrop/airdrop_server.py index 7449bf2..ec4a8c7 100644 --- a/airdrop/airdrop_server.py +++ b/airdrop/airdrop_server.py @@ -8,7 +8,7 @@ PointsRecord, ProjectInterAction ) -from services.savour_rpc import airdrop_pb2_grpc, common_pb2, airdrop_pb2 +from services.savour_rpc import airdrop_pb2_grpc, airdrop_pb2 from django.conf import settings tz = pytz.timezone(settings.TIME_ZONE) @@ -51,7 +51,7 @@ def submitDppLinkPoints(self, request, context) -> airdrop_pb2.DppLinkPointsRep: airdrop_user = airdrop_tmp_user else: return airdrop_pb2.DppLinkPointsRep( - code=common_pb2.SUCCESS, + code=200, msg="already arrive to daily or max points", ) else: @@ -67,6 +67,6 @@ def submitDppLinkPoints(self, request, context) -> airdrop_pb2.DppLinkPointsRep: points=projectInteraction.once_points ) return airdrop_pb2.DppLinkPointsRep( - code=common_pb2.SUCCESS, + code=200, msg="submit dapplink points success", ) diff --git a/services/airdrop_client.py b/services/airdrop_client.py index c57977d..5ec6062 100644 --- a/services/airdrop_client.py +++ b/services/airdrop_client.py @@ -14,10 +14,12 @@ def __init__(self): self.stub = airdrop_pb2_grpc.AirdropServiceStub(channel) def submit_dapplink_points(self, type: int, consumer_token: str = None) -> airdrop_pb2.DppLinkPointsRep: - return self.stub.submitDppLinkPoints( + ret_value = self.stub.submitDppLinkPoints( airdrop_pb2.DppLinkPointsReq( consumer_token=consumer_token, - type="1", + type="0", address="0xf6f75BF38ED11F984Ac195e8b8a61Df73bA48892" ) ) + print("ret===", ret_value.code, ret_value.msg) + return ret_value diff --git a/services/savour_rpc/airdrop_grpc.py b/services/savour_rpc/airdrop_grpc.py new file mode 100644 index 0000000..659691e --- /dev/null +++ b/services/savour_rpc/airdrop_grpc.py @@ -0,0 +1,40 @@ +# Generated by the Protocol Buffers compiler. DO NOT EDIT! +# source: savour_rpc/airdrop.proto +# plugin: grpclib.plugin.main +import abc +import typing + +import grpclib.const +import grpclib.client +if typing.TYPE_CHECKING: + import grpclib.server + +from services.savour_rpc import airdrop_pb2 + + +class AirdropServiceBase(abc.ABC): + + @abc.abstractmethod + async def submitDppLinkPoints(self, stream: 'grpclib.server.Stream[savour_rpc.airdrop_pb2.DppLinkPointsReq, savour_rpc.airdrop_pb2.DppLinkPointsRep]') -> None: + pass + + def __mapping__(self) -> typing.Dict[str, grpclib.const.Handler]: + return { + '/services.savour_rpc.airdrop.AirdropService/submitDppLinkPoints': grpclib.const.Handler( + self.submitDppLinkPoints, + grpclib.const.Cardinality.UNARY_UNARY, + airdrop_pb2.DppLinkPointsReq, + airdrop_pb2.DppLinkPointsRep, + ), + } + + +class AirdropServiceStub: + + def __init__(self, channel: grpclib.client.Channel) -> None: + self.submitDppLinkPoints = grpclib.client.UnaryUnaryMethod( + channel, + '/services.savour_rpc.airdrop.AirdropService/submitDppLinkPoints', + airdrop_pb2.DppLinkPointsReq, + airdrop_pb2.DppLinkPointsRep, + ) diff --git a/services/savour_rpc/airdrop_pb2.py b/services/savour_rpc/airdrop_pb2.py index 01cf2b4..4046d6b 100644 --- a/services/savour_rpc/airdrop_pb2.py +++ b/services/savour_rpc/airdrop_pb2.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: savourrpc/airdrop.proto +# source: savour_rpc/airdrop.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message @@ -11,46 +11,44 @@ _sym_db = _symbol_database.Default() -from services.savour_rpc import common_pb2 as savourrpc_dot_common__pb2 DESCRIPTOR = _descriptor.FileDescriptor( - name='savourrpc/airdrop.proto', - package='savourrpc.airdrop', + name='savour_rpc/airdrop.proto', + package='services.savour_rpc.airdrop', syntax='proto3', serialized_options=b'\n\024group.savour.airdropZ\017./proto/airdrop', create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x17savourrpc/airdrop.proto\x12\x11savourrpc.airdrop\x1a\x16savourrpc/common.proto\"I\n\x10\x44ppLinkPointsReq\x12\x16\n\x0e\x63onsumer_token\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x03 \x01(\t\"D\n\x10\x44ppLinkPointsRep\x12#\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x15.savourrpc.ReturnCode\x12\x0b\n\x03msg\x18\x02 \x01(\t2s\n\x0e\x41irdropService\x12\x61\n\x13submitDppLinkPoints\x12#.savourrpc.airdrop.DppLinkPointsReq\x1a#.savourrpc.airdrop.DppLinkPointsRep\"\x00\x42\'\n\x14group.savour.airdropZ\x0f./proto/airdropb\x06proto3' - , - dependencies=[savourrpc_dot_common__pb2.DESCRIPTOR,]) + serialized_pb=b'\n\x18savour_rpc/airdrop.proto\x12\x1bservices.savour_rpc.airdrop\"I\n\x10\x44ppLinkPointsReq\x12\x16\n\x0e\x63onsumer_token\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x03 \x01(\t\"-\n\x10\x44ppLinkPointsRep\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0b\n\x03msg\x18\x02 \x01(\t2\x87\x01\n\x0e\x41irdropService\x12u\n\x13submitDppLinkPoints\x12-.services.savour_rpc.airdrop.DppLinkPointsReq\x1a-.services.savour_rpc.airdrop.DppLinkPointsRep\"\x00\x42\'\n\x14group.savour.airdropZ\x0f./proto/airdropb\x06proto3' +) _DPPLINKPOINTSREQ = _descriptor.Descriptor( name='DppLinkPointsReq', - full_name='savourrpc.airdrop.DppLinkPointsReq', + full_name='services.savour_rpc.airdrop.DppLinkPointsReq', filename=None, file=DESCRIPTOR, containing_type=None, create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( - name='consumer_token', full_name='savourrpc.airdrop.DppLinkPointsReq.consumer_token', index=0, + name='consumer_token', full_name='services.savour_rpc.airdrop.DppLinkPointsReq.consumer_token', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='type', full_name='savourrpc.airdrop.DppLinkPointsReq.type', index=1, + name='type', full_name='services.savour_rpc.airdrop.DppLinkPointsReq.type', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='address', full_name='savourrpc.airdrop.DppLinkPointsReq.address', index=2, + name='address', full_name='services.savour_rpc.airdrop.DppLinkPointsReq.address', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -68,28 +66,28 @@ extension_ranges=[], oneofs=[ ], - serialized_start=70, - serialized_end=143, + serialized_start=57, + serialized_end=130, ) _DPPLINKPOINTSREP = _descriptor.Descriptor( name='DppLinkPointsRep', - full_name='savourrpc.airdrop.DppLinkPointsRep', + full_name='services.savour_rpc.airdrop.DppLinkPointsRep', filename=None, file=DESCRIPTOR, containing_type=None, create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( - name='code', full_name='savourrpc.airdrop.DppLinkPointsRep.code', index=0, - number=1, type=14, cpp_type=8, label=1, + name='code', full_name='services.savour_rpc.airdrop.DppLinkPointsRep.code', index=0, + number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='msg', full_name='savourrpc.airdrop.DppLinkPointsRep.msg', index=1, + name='msg', full_name='services.savour_rpc.airdrop.DppLinkPointsRep.msg', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=b"".decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -107,26 +105,25 @@ extension_ranges=[], oneofs=[ ], - serialized_start=145, - serialized_end=213, + serialized_start=132, + serialized_end=177, ) -_DPPLINKPOINTSREP.fields_by_name['code'].enum_type = savourrpc_dot_common__pb2._RETURNCODE DESCRIPTOR.message_types_by_name['DppLinkPointsReq'] = _DPPLINKPOINTSREQ DESCRIPTOR.message_types_by_name['DppLinkPointsRep'] = _DPPLINKPOINTSREP _sym_db.RegisterFileDescriptor(DESCRIPTOR) DppLinkPointsReq = _reflection.GeneratedProtocolMessageType('DppLinkPointsReq', (_message.Message,), { 'DESCRIPTOR' : _DPPLINKPOINTSREQ, - '__module__' : 'savourrpc.airdrop_pb2' - # @@protoc_insertion_point(class_scope:savourrpc.airdrop.DppLinkPointsReq) + '__module__' : 'savour_rpc.airdrop_pb2' + # @@protoc_insertion_point(class_scope:services.savour_rpc.airdrop.DppLinkPointsReq) }) _sym_db.RegisterMessage(DppLinkPointsReq) DppLinkPointsRep = _reflection.GeneratedProtocolMessageType('DppLinkPointsRep', (_message.Message,), { 'DESCRIPTOR' : _DPPLINKPOINTSREP, - '__module__' : 'savourrpc.airdrop_pb2' - # @@protoc_insertion_point(class_scope:savourrpc.airdrop.DppLinkPointsRep) + '__module__' : 'savour_rpc.airdrop_pb2' + # @@protoc_insertion_point(class_scope:services.savour_rpc.airdrop.DppLinkPointsRep) }) _sym_db.RegisterMessage(DppLinkPointsRep) @@ -135,17 +132,17 @@ _AIRDROPSERVICE = _descriptor.ServiceDescriptor( name='AirdropService', - full_name='savourrpc.airdrop.AirdropService', + full_name='services.savour_rpc.airdrop.AirdropService', file=DESCRIPTOR, index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=215, - serialized_end=330, + serialized_start=180, + serialized_end=315, methods=[ _descriptor.MethodDescriptor( name='submitDppLinkPoints', - full_name='savourrpc.airdrop.AirdropService.submitDppLinkPoints', + full_name='services.savour_rpc.airdrop.AirdropService.submitDppLinkPoints', index=0, containing_service=None, input_type=_DPPLINKPOINTSREQ, diff --git a/services/savour_rpc/airdrop_pb2_grpc.py b/services/savour_rpc/airdrop_pb2_grpc.py index c5e5a9b..1fcb4ab 100644 --- a/services/savour_rpc/airdrop_pb2_grpc.py +++ b/services/savour_rpc/airdrop_pb2_grpc.py @@ -2,7 +2,7 @@ """Client and server classes corresponding to protobuf-defined services.""" import grpc -from services.savour_rpc import airdrop_pb2 as savourrpc_dot_airdrop__pb2 +from services.savour_rpc import airdrop_pb2 as savour__rpc_dot_airdrop__pb2 class AirdropServiceStub(object): @@ -15,9 +15,9 @@ def __init__(self, channel): channel: A grpc.Channel. """ self.submitDppLinkPoints = channel.unary_unary( - '/savourrpc.airdrop.AirdropService/submitDppLinkPoints', - request_serializer=savourrpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString, - response_deserializer=savourrpc_dot_airdrop__pb2.DppLinkPointsRep.FromString, + '/services.savour_rpc.airdrop.AirdropService/submitDppLinkPoints', + request_serializer=savour__rpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString, + response_deserializer=savour__rpc_dot_airdrop__pb2.DppLinkPointsRep.FromString, ) @@ -35,12 +35,12 @@ def add_AirdropServiceServicer_to_server(servicer, server): rpc_method_handlers = { 'submitDppLinkPoints': grpc.unary_unary_rpc_method_handler( servicer.submitDppLinkPoints, - request_deserializer=savourrpc_dot_airdrop__pb2.DppLinkPointsReq.FromString, - response_serializer=savourrpc_dot_airdrop__pb2.DppLinkPointsRep.SerializeToString, + request_deserializer=savour__rpc_dot_airdrop__pb2.DppLinkPointsReq.FromString, + response_serializer=savour__rpc_dot_airdrop__pb2.DppLinkPointsRep.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( - 'savourrpc.airdrop.AirdropService', rpc_method_handlers) + 'services.savour_rpc.airdrop.AirdropService', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) @@ -59,8 +59,8 @@ def submitDppLinkPoints(request, wait_for_ready=None, timeout=None, metadata=None): - return grpc.experimental.unary_unary(request, target, '/savourrpc.airdrop.AirdropService/submitDppLinkPoints', - savourrpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString, - savourrpc_dot_airdrop__pb2.DppLinkPointsRep.FromString, + return grpc.experimental.unary_unary(request, target, '/services.savour_rpc.airdrop.AirdropService/submitDppLinkPoints', + savour__rpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString, + savour__rpc_dot_airdrop__pb2.DppLinkPointsRep.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/services/savour_rpc/common_pb2.py b/services/savour_rpc/common_pb2.py index 03df23b..8b47fc9 100644 --- a/services/savour_rpc/common_pb2.py +++ b/services/savour_rpc/common_pb2.py @@ -18,9 +18,9 @@ name='savourrpc/common.proto', package='savourrpc', syntax='proto3', - serialized_options=b'Z2git.savour.io/savour/savourrpc/go-savourrpc/common', + serialized_options=b'Z\016./proto/common', create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x16savourrpc/common.proto\x12\tsavourrpc*$\n\nReturnCode\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\x42\x34Z2git.savour.io/savour/savourrpc/go-savourrpc/commonb\x06proto3' + serialized_pb=b'\n\x16savourrpc/common.proto\x12\tsavourrpc*$\n\nReturnCode\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\x42\x10Z\x0e./proto/commonb\x06proto3' ) _RETURNCODE = _descriptor.EnumDescriptor(