This is a repo created for an internal presentation to demonstrate some high level concepts of gRPC in Python.
This repo contains:
- A tariff service protobuf based on the features visible on the Tariff UI tool wireframe.
- A Python gRPC server implementation of
tariff.proto
intariff_server/
- A Python gRPC stub (client) implementation of
tariff.proto
intariff_client/
- A Typescript gRPC stub (client) implementation of
tariff.proto
intypescript/client/static_client
usingts-proto
andgrpc-js
- A Typescript gRPC stub (client) implementation of
tariff.proto
intypescript/client/static_client
usingts-proto
andnice-grpc
poetry install
In ./tariff_server/tariff_server
and ./tariff_client/tariff_client
, use the following command to generate bulb/tariff/v1/__init__.py
:
poetry run python -m grpc_tools.protoc \
-I ../protos \
--python_betterproto_out=tariff_client \
../protos/tariff.proto
Rerun this step if you've made changes to the protobuf tariff.proto
.
The server code lives under ./tariff_server
, and the stub (client) lives under ./tariff_client
.
They can be updated independently of each other in the case of new field or features added in contract.
cd
into ./tariff_[server|client]
, then:
poetry run python -m tariff_[server|client].[server|client]
yarn install
yarn proto
yarn start