Python Grpc

Python GrpcPythonLatest version

Released:

GRPC is a modern open source high performance Remote Procedure Call (RPC) framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of. Sep 13, 2016 In the linked Python example, you define a protolibrary, then create a pyprotolibrary, then create a pygrpclibrary. Furthermore, the pygrpclibrary requires a 'srcs' attribute of which it is taking the name of the protolibrary and in deps it takes the pyprotolibrary. What is going on here?

Simplifies gRPC interceptors

Project description

Simplified Python gRPC interceptors.

The Python grpc package provides service interceptors, but they're a bit hard touse because of their flexibility. The grpc interceptors don't have direct accessto the request and response objects, or the service context. Access to these are oftendesired, to be able to log data in the request or response, or set status codes on thecontext.

To just get the interceptors (and probably not write your own):

To also get the testing framework, which is good if you're writing your own interceptors:

Server Interceptor

To define your own interceptor (we can use ExceptionToStatusInterceptor as an example):

Then inject your interceptor when you create the grpc server:

Grpc

To use ExceptionToStatusInterceptor:

This results in the gRPC status status code being set to NOT_FOUND,and the details 'Sorry, your thing is missing'. This saves you the hassle ofcatching exceptions in your service handler, or passing the context down intohelper functions so they can call context.abort or context.set_code. It allowsthe more Pythonic approach of just raising an exception from anywhere in the code,and having it be handled automatically.

Client Interceptor

We will use an invocation metadata injecting interceptor as an example of defininga client interceptor:

Now inject your interceptor when you create the grpc channel:

Client interceptors can also be used to retry RPCs that fail due to specific errors, ora host of other use cases. There are some basic approaches in the tests to get youstarted.

Read the complete documentation here.

Grpc

Release historyRelease notifications RSS feed

0.13.0

0.12.0

0.11.0

0.10.0

0.9.0

0.8.0

0.1.0

Download files

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

Python Grpc Dns

Files for grpc-interceptor, version 0.13.0
Filename, sizeFile typePython versionUpload dateHashes
Filename, size grpc_interceptor-0.13.0-py3-none-any.whl (17.5 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size grpc-interceptor-0.13.0.tar.gz (15.7 kB) File type Source Python version None Upload dateHashes
Close

Hashes for grpc_interceptor-0.13.0-py3-none-any.whl

Hashes for grpc_interceptor-0.13.0-py3-none-any.whl
AlgorithmHash digest
SHA2560f0f2844798c5c81d4fa54fd00356bc3c44d0b1604fa90763839fae960e21f6f
MD5dcb9354766f0769ac07b19d44bf0edcb
BLAKE2-256b8a432ad7b3c8afcf54bd8434fb1ac166b1efd805d7fa93e7cf752dfbfad8015
Close

Hashes for grpc-interceptor-0.13.0.tar.gz

Python Grpcio

Hashes for grpc-interceptor-0.13.0.tar.gz
AlgorithmHash digest
SHA25623ec906bd38bd09a6c9ca0ed44432ee8903d19aa9c4dce738c46469cb01f4a78
MD59980cea29c9890f7c1ed7333845eae3b
BLAKE2-2562cb4c73b8a12278ce9d5a6ffa6f2d49364d9130753a830266f65bfe80f5f97f4