passing metadata from context to method
This commit is contained in:
parent
0602b4aee7
commit
12301fcd01
1 changed files with 2 additions and 1 deletions
|
@ -40,7 +40,8 @@ class RecommendationService(demo_pb2_grpc.RecommendationServiceServicer):
|
|||
def ListRecommendations(self, request, context):
|
||||
max_responses = 5
|
||||
# fetch list of products from product catalog stub
|
||||
cat_response = product_catalog_stub.ListProducts(demo_pb2.Empty())
|
||||
metadata = context.invocation_metadata()
|
||||
cat_response = product_catalog_stub.ListProducts(demo_pb2.Empty(), metadata=metadata)
|
||||
product_ids = [x.id for x in cat_response.products]
|
||||
filtered_products = list(set(product_ids)-set(request.product_ids))
|
||||
num_products = len(filtered_products)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue