Skip to main content

This tools for generating grpc files

Project description

# gRPC tools
This is tool for auto generating *.proto and mapping django model with protobuf.

# Requirements
- Python (2.7, 3.4, 3.5, 3.6, 3.7)
- Django (1.11, 2.0, 2.1, 2.2)

# Installation
Install using pip
```
pip install grpc-tls
```

Add 'grpc_tls' to your INSTALLED_APPS setting.
```
INSTALLED_APPS = (
...
'grpc_tls',
)
```

# Usage
Generate *.proto file
```
python manage.py grpc_tls
```

All files will be generated in `grpc_dir/*`

# Runserver
Create a django command line: `run_grpc.py`
```
import grpc
from concurrent import futures
from django.core.management.base import BaseCommand

from grpc_dir import auto_grpc_app, grpc_app_pb2_grpc

class Command(BaseCommand):
help = 'Start gRPC server'

def handle(self, *args, **options):
server = grpc.server(futures.ThreadPoolExecutor(
max_workers=10))
grpc_app_pb2_grpc.add_GRPCAPPServicer_to_server(
auto_grpc_app.AutoGRPC(), server)
server.add_insecure_port('[::]:50051')
server.start()
print('server started on port 50051 ...')
try:
while True:
pass
except KeyboardInterrupt:
server.stop(0)
```

Then start gRPC server:
```
python manage.py run_grpc
```
# Notes
DO NOT FILES IN `grpc_dir`

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for grpc-tls, version 1.1.6
Filename, size File type Python version Upload date Hashes
Filename, size grpc-tls-1.1.6.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page