modify return and function names

This commit is contained in:
Richie 2023-10-23 22:25:15 +08:00
parent 16a00f0b96
commit 8eaad6659e
4 changed files with 22 additions and 22 deletions

View File

@ -3,8 +3,8 @@ syntax = "proto3";
package dynamo_db; package dynamo_db;
service Dynamo_DB { service Dynamo_DB {
rpc CheckFile (Request) returns (Response) {} rpc CheckHash (Request) returns (Response) {}
rpc UpdateFile (Request) returns (Response) {} rpc UpdateHash (Request) returns (Response) {}
} }
message Request { message Request {

View File

@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x64ynamo.proto\x12\tdynamo_db\"\x1c\n\x07Request\x12\x11\n\tfile_hash\x18\x02 \x01(\t\"\x1c\n\x08Response\x12\x10\n\x08is_exist\x18\x01 \x01(\x08\x32|\n\tDynamo_DB\x12\x36\n\tCheckFile\x12\x12.dynamo_db.Request\x1a\x13.dynamo_db.Response\"\x00\x12\x37\n\nUpdateFile\x12\x12.dynamo_db.Request\x1a\x13.dynamo_db.Response\"\x00\x62\x06proto3') DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x64ynamo.proto\x12\tdynamo_db\"\x1c\n\x07Request\x12\x11\n\tfile_hash\x18\x02 \x01(\t\"\x1c\n\x08Response\x12\x10\n\x08is_exist\x18\x01 \x01(\x08\x32|\n\tDynamo_DB\x12\x36\n\tCheckHash\x12\x12.dynamo_db.Request\x1a\x13.dynamo_db.Response\"\x00\x12\x37\n\nUpdateHash\x12\x12.dynamo_db.Request\x1a\x13.dynamo_db.Response\"\x00\x62\x06proto3')
_globals = globals() _globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)

View File

@ -14,13 +14,13 @@ class Dynamo_DBStub(object):
Args: Args:
channel: A grpc.Channel. channel: A grpc.Channel.
""" """
self.CheckFile = channel.unary_unary( self.CheckHash = channel.unary_unary(
'/dynamo_db.Dynamo_DB/CheckFile', '/dynamo_db.Dynamo_DB/CheckHash',
request_serializer=dynamo__pb2.Request.SerializeToString, request_serializer=dynamo__pb2.Request.SerializeToString,
response_deserializer=dynamo__pb2.Response.FromString, response_deserializer=dynamo__pb2.Response.FromString,
) )
self.UpdateFile = channel.unary_unary( self.UpdateHash = channel.unary_unary(
'/dynamo_db.Dynamo_DB/UpdateFile', '/dynamo_db.Dynamo_DB/UpdateHash',
request_serializer=dynamo__pb2.Request.SerializeToString, request_serializer=dynamo__pb2.Request.SerializeToString,
response_deserializer=dynamo__pb2.Response.FromString, response_deserializer=dynamo__pb2.Response.FromString,
) )
@ -29,13 +29,13 @@ class Dynamo_DBStub(object):
class Dynamo_DBServicer(object): class Dynamo_DBServicer(object):
"""Missing associated documentation comment in .proto file.""" """Missing associated documentation comment in .proto file."""
def CheckFile(self, request, context): def CheckHash(self, request, context):
"""Missing associated documentation comment in .proto file.""" """Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!') context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') raise NotImplementedError('Method not implemented!')
def UpdateFile(self, request, context): def UpdateHash(self, request, context):
"""Missing associated documentation comment in .proto file.""" """Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!') context.set_details('Method not implemented!')
@ -44,13 +44,13 @@ class Dynamo_DBServicer(object):
def add_Dynamo_DBServicer_to_server(servicer, server): def add_Dynamo_DBServicer_to_server(servicer, server):
rpc_method_handlers = { rpc_method_handlers = {
'CheckFile': grpc.unary_unary_rpc_method_handler( 'CheckHash': grpc.unary_unary_rpc_method_handler(
servicer.CheckFile, servicer.CheckHash,
request_deserializer=dynamo__pb2.Request.FromString, request_deserializer=dynamo__pb2.Request.FromString,
response_serializer=dynamo__pb2.Response.SerializeToString, response_serializer=dynamo__pb2.Response.SerializeToString,
), ),
'UpdateFile': grpc.unary_unary_rpc_method_handler( 'UpdateHash': grpc.unary_unary_rpc_method_handler(
servicer.UpdateFile, servicer.UpdateHash,
request_deserializer=dynamo__pb2.Request.FromString, request_deserializer=dynamo__pb2.Request.FromString,
response_serializer=dynamo__pb2.Response.SerializeToString, response_serializer=dynamo__pb2.Response.SerializeToString,
), ),
@ -65,7 +65,7 @@ class Dynamo_DB(object):
"""Missing associated documentation comment in .proto file.""" """Missing associated documentation comment in .proto file."""
@staticmethod @staticmethod
def CheckFile(request, def CheckHash(request,
target, target,
options=(), options=(),
channel_credentials=None, channel_credentials=None,
@ -75,14 +75,14 @@ class Dynamo_DB(object):
wait_for_ready=None, wait_for_ready=None,
timeout=None, timeout=None,
metadata=None): metadata=None):
return grpc.experimental.unary_unary(request, target, '/dynamo_db.Dynamo_DB/CheckFile', return grpc.experimental.unary_unary(request, target, '/dynamo_db.Dynamo_DB/CheckHash',
dynamo__pb2.Request.SerializeToString, dynamo__pb2.Request.SerializeToString,
dynamo__pb2.Response.FromString, dynamo__pb2.Response.FromString,
options, channel_credentials, options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata) insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod @staticmethod
def UpdateFile(request, def UpdateHash(request,
target, target,
options=(), options=(),
channel_credentials=None, channel_credentials=None,
@ -92,7 +92,7 @@ class Dynamo_DB(object):
wait_for_ready=None, wait_for_ready=None,
timeout=None, timeout=None,
metadata=None): metadata=None):
return grpc.experimental.unary_unary(request, target, '/dynamo_db.Dynamo_DB/UpdateFile', return grpc.experimental.unary_unary(request, target, '/dynamo_db.Dynamo_DB/UpdateHash',
dynamo__pb2.Request.SerializeToString, dynamo__pb2.Request.SerializeToString,
dynamo__pb2.Response.FromString, dynamo__pb2.Response.FromString,
options, channel_credentials, options, channel_credentials,

View File

@ -19,21 +19,21 @@ hex_pattern = re.compile("^[a-fA-F0-9]+$")
def check_sha256(sha256): def check_sha256(sha256):
response = sha256_table.get_item(Key={'sha256': sha256}) response = sha256_table.get_item(Key={'sha256': sha256})
return True if 'Item' in response else False return 'Item' in response
def check_sha1(sha1): def check_sha1(sha1):
response = sha1_table.get_item(Key={'sha1': sha1}) response = sha1_table.get_item(Key={'sha1': sha1})
return True if 'Item' in response else False return 'Item' in response
def check_md5(md5): def check_md5(md5):
response = md5_table.get_item(Key={'md5': md5}) response = md5_table.get_item(Key={'md5': md5})
return True if 'Item' in response else False return 'Item' in response
class Dynamo(pb2_grpc.Dynamo_DBServicer): class Dynamo(pb2_grpc.Dynamo_DBServicer):
def CheckFile(self, request, context): def CheckHash(self, request, context):
if not hex_pattern.match(request.file_hash): if not hex_pattern.match(request.file_hash):
return pb2.Response(is_exist=False) return pb2.Response(is_exist=False)
else: else:
@ -47,7 +47,7 @@ class Dynamo(pb2_grpc.Dynamo_DBServicer):
else: else:
return pb2.Response(is_exist=False) return pb2.Response(is_exist=False)
def UpdateFile(self, request, context): def UpdateHash(self, request, context):
if not hex_pattern.match(request.file_hash): if not hex_pattern.match(request.file_hash):
return pb2.Response(is_exist=False) return pb2.Response(is_exist=False)
else: else: