regenerated protos
This commit is contained in:
parent
933a05205f
commit
5cdc65777a
3 changed files with 61 additions and 102 deletions
File diff suppressed because one or more lines are too long
|
@ -283,8 +283,8 @@ class CurrencyServiceStub(object):
|
||||||
)
|
)
|
||||||
self.Convert = channel.unary_unary(
|
self.Convert = channel.unary_unary(
|
||||||
'/hipstershop.CurrencyService/Convert',
|
'/hipstershop.CurrencyService/Convert',
|
||||||
request_serializer=demo__pb2.ConversionRequest.SerializeToString,
|
request_serializer=demo__pb2.CurrencyConversionRequest.SerializeToString,
|
||||||
response_deserializer=demo__pb2.ConversionResponse.FromString,
|
response_deserializer=demo__pb2.Money.FromString,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,8 +317,8 @@ def add_CurrencyServiceServicer_to_server(servicer, server):
|
||||||
),
|
),
|
||||||
'Convert': grpc.unary_unary_rpc_method_handler(
|
'Convert': grpc.unary_unary_rpc_method_handler(
|
||||||
servicer.Convert,
|
servicer.Convert,
|
||||||
request_deserializer=demo__pb2.ConversionRequest.FromString,
|
request_deserializer=demo__pb2.CurrencyConversionRequest.FromString,
|
||||||
response_serializer=demo__pb2.ConversionResponse.SerializeToString,
|
response_serializer=demo__pb2.Money.SerializeToString,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
generic_handler = grpc.method_handlers_generic_handler(
|
generic_handler = grpc.method_handlers_generic_handler(
|
||||||
|
|
|
@ -9,15 +9,14 @@ import os
|
||||||
class RecommendationService(demo_pb2_grpc.RecommendationServiceServicer):
|
class RecommendationService(demo_pb2_grpc.RecommendationServiceServicer):
|
||||||
def ListRecommendations(self, request, context):
|
def ListRecommendations(self, request, context):
|
||||||
max_responses = 5
|
max_responses = 5
|
||||||
print("handling request")
|
|
||||||
|
|
||||||
# get list of products
|
# get list of products
|
||||||
cat_response = stub.ListProducts(demo_pb2.Empty())
|
cat_response = stub.ListProducts(demo_pb2.Empty())
|
||||||
num_prodcuts = len(cat_response.products)
|
num_prodcuts = len(cat_response.products)
|
||||||
|
|
||||||
indices = random.sample(range(num_prodcuts), min(max_responses, num_prodcuts))
|
indices = random.sample(range(num_prodcuts), min(max_responses, num_prodcuts))
|
||||||
prod_list = [str(cat_response.products[i].id) for i in indices]
|
prod_list = [cat_response.products[i].id for i in indices]
|
||||||
print(indices, prod_list)
|
print("handling request: {}".format(prod_list))
|
||||||
|
|
||||||
response = demo_pb2.ListRecommendationsResponse()
|
response = demo_pb2.ListRecommendationsResponse()
|
||||||
response.product_ids.extend(prod_list)
|
response.product_ids.extend(prod_list)
|
||||||
|
|
Loading…
Reference in a new issue