Skip to main content

Easy Django based gRPC service

Project description

# django-grpc
Easy way to launch gRPC server with access to Django ORM and other handy staff.
gRPC request are much faster that traditional HTTP requests because are not
passed through standard middlewares.

## Installation

```bash
pip install django-grpc
```

Update settings.py
```python
INSTALLED_APPS = [
# ...
'django_grpc',
]

GRPCSERVER = {
'servicers': ['dotted.path.to.callback'],
'interceptors': ['dotted.path.to.interceptor_class',],
'maximum_concurrent_rpcs': None,
}
```

The callback must look like following:
```python
import my_pb2
import my_pb2_grpc

def grpc_hook(server):
my_pb2_grpc.add_MYServicer_to_server(MYServicer(), server)

...
class MYServicer(my_pb2_grpc.MYServicer):

def GetPage(self, request, context):
response = my_pb2.PageResponse(title="Demo object")
return response
```

## Usage
```bash
python manage.py grpcserver
```

For developer's convenience add `--autoreload` flag during development.


## Serializers
There is an easy way to serialize django model to gRPC message using `django_grpc.serializers.serialize_model`.


## Testing
You can call methods of your servicer and decode them using `django_grpc.serializers.deserialize_message` that
will convert gRPC messages to python dictionary




History
-------

0.1.0 (2019-01-18)
++++++++++++++++++

* First release on PyPI.


Project details


Download files

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

Source Distribution

django-grpc-0.1.8.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

django_grpc-0.1.8-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-grpc-0.1.8.tar.gz.

File metadata

  • Download URL: django-grpc-0.1.8.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for django-grpc-0.1.8.tar.gz
Algorithm Hash digest
SHA256 55c3e9e39c154d87a36b1164363c2d8776e0c1ddc3f926e1142fce071b744570
MD5 d679a442c54cd14fbd89eb090f679426
BLAKE2b-256 c2e644dbd457ffafe86dd121ac92943e5b32efaa6b540792ab4ead7f486326f0

See more details on using hashes here.

File details

Details for the file django_grpc-0.1.8-py2.py3-none-any.whl.

File metadata

  • Download URL: django_grpc-0.1.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for django_grpc-0.1.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d721cd3fcf835ca85800e64677f153fc514d4e924049edc68a4aed5932a4c6df
MD5 1cbc929507a7d8987ffcea15a484cf3c
BLAKE2b-256 555598d5983407d44b01f0f451a53a03007166465bd9a5ccd95f572f4533d476

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page