gRPyC : A lightweight framework to ease developpment of multiple-services using gRPC with python
(Support windows only for now) TODO : Circular dependencies check, and add dependencies of dependencies
File structuration :
sample project
β requirements.txt <- Dependencies for this project developpment
β
ββββservices
β ββββservice1
β β ββββdata <- Sample database .json
β β ββββpb2 <- Where the pb2 generated files will be
β β β service1.py <- The servicer class file
β β β Dockerfile <- To easily deploy the service later with Docker
β β β requirements.txt <- Used by Docker to install dependencies
β β
β ββββservice2
β ββββ...
β β
β ββββclient <- The client folder, NB : It is not a service, and you can't name a service 'client'
β β It is for testing your services only, you can delete it if you test your service with something else
β ββββprotos <- pb2 for each service will be also generated here
β β client.py <- The client main script used to make requests to our services to test them
β
ββββprotos
β β service1.proto <- Proto file for service1
β β service2.proto <- Proto file for service2
β β base.proto <- Proto file imported in other proto files, not representing a service
β β ...NB : A the service name should be the same than its proto file name
β
ββββvenv <- We suggest you to use a virual environment
How to start :
- Create your 'protos' & 'services' directories
- Then run these commands (at the root of the project)
-
python -m venv venv
(create a virtual environment) - Get in your freshly made virtual environment, then install grpyc :
-
pip install grpyc
(PYPI) - Now you can run
grpyc -ns myService1
to create a new service
Commands list
Command | Description |
---|---|
-c, --compile-client | Will compile all protos for each service and copy them into the client |
-cs, --compile-service TEXT | Will compile the given service |
-s, --run-service TEXT | Will run the given service |
-ns, --new-service TEXT | Will create a proto file and a dir for the service, run it with no text to create a client service |
--help | Show help |
NB : These command must be executed at the root of your project, where your services and protos directories stand