Created
February 28, 2019 09:44
-
-
Save kooba/37a603d974ac6a74d36941dd06c45adf to your computer and use it in GitHub Desktop.
gRPC Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from nameko.web.handlers import http | |
from nameko_grpc.dependency_provider import GrpcProxy | |
from products.products_pb2 import GetProduct | |
from products.products_pb2_grpc import productsStub | |
class ClientService: | |
name = "client" | |
products_grpc = GrpcProxy("//127.0.0.1", productsStub) | |
@http("GET", "/product/<int:value>") | |
def get_product(self, request, value): | |
response = self.products_grpc.get_product(GetProduct(id=value)) | |
return json.dumps({"id": response.id, "title": response.title}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment