Skip to content

Instantly share code, notes, and snippets.

@kooba
Created February 28, 2019 09:44
Show Gist options
  • Save kooba/37a603d974ac6a74d36941dd06c45adf to your computer and use it in GitHub Desktop.
Save kooba/37a603d974ac6a74d36941dd06c45adf to your computer and use it in GitHub Desktop.
gRPC Client
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