All Projects → vmagamedov → Grpclib

vmagamedov / Grpclib

Licence: bsd-3-clause
Pure-Python gRPC implementation for asyncio

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Grpclib

Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-76.1%)
Mutual labels:  microservices, grpc, protobuf
Kratos
A modular-designed and easy-to-use microservices framework in Go.
Stars: ✭ 15,844 (+2476.26%)
Mutual labels:  microservices, grpc, protobuf
Yarpc Go
A message passing platform for Go
Stars: ✭ 285 (-53.66%)
Mutual labels:  microservices, grpc, protobuf
Protoactor Go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 3,934 (+539.67%)
Mutual labels:  grpc, protobuf
Ts Proto
An idiomatic protobuf generator for TypeScript
Stars: ✭ 340 (-44.72%)
Mutual labels:  grpc, protobuf
Chronos
📊 📊 📊 Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.
Stars: ✭ 347 (-43.58%)
Mutual labels:  microservices, grpc
Kocircuit
Ko: A generic type-safe language for concurrent, stateful, deadlock-free systems and protocol manipulations
Stars: ✭ 305 (-50.41%)
Mutual labels:  grpc, protobuf
Gruf
gRPC Ruby Framework
Stars: ✭ 411 (-33.17%)
Mutual labels:  grpc, protobuf
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (-39.35%)
Mutual labels:  microservices, grpc
Python Betterproto
Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
Stars: ✭ 412 (-33.01%)
Mutual labels:  grpc, asyncio
Protobuf
[Looking for new ownership] Protocol Buffers for Go with Gadgets
Stars: ✭ 4,998 (+712.68%)
Mutual labels:  grpc, protobuf
Gokit
Go Examples: From basics to distributed systems
Stars: ✭ 325 (-47.15%)
Mutual labels:  microservices, grpc
Rejoiner
Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources
Stars: ✭ 3,432 (+458.05%)
Mutual labels:  grpc, protobuf
Grpc Example
An example of using Go gRPC and tools from the greater gRPC ecosystem together with the GoGo Protobuf Project.
Stars: ✭ 352 (-42.76%)
Mutual labels:  grpc, protobuf
Vertx Zero
Zero Framework:http://www.vertxup.cn
Stars: ✭ 320 (-47.97%)
Mutual labels:  microservices, grpc
Kroto Plus
gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Stars: ✭ 400 (-34.96%)
Mutual labels:  grpc, protobuf
Nrpc
nRPC is like gRPC, but over NATS
Stars: ✭ 440 (-28.46%)
Mutual labels:  grpc, protobuf
Proteus
Generate .proto files from Go source code.
Stars: ✭ 593 (-3.58%)
Mutual labels:  grpc, protobuf
Grpcurl
Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
Stars: ✭ 6,149 (+899.84%)
Mutual labels:  grpc, protobuf
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+451.54%)
Mutual labels:  microservices, grpc

Pure-Python gRPC implementation for asyncio

|project|_ |documentation|_ |version|_ |tag|_ |license|_

This project is based on hyper-h2_ and requires Python >= 3.6.

.. contents:: :local:

Example


See `examples`_ directory in the project's repository for all available
examples.

Client
------

.. code-block:: python3

  import asyncio

  from grpclib.client import Channel

  # generated by protoc
  from .helloworld_pb2 import HelloRequest, HelloReply
  from .helloworld_grpc import GreeterStub


  async def main():
      async with Channel('127.0.0.1', 50051) as channel:
          greeter = GreeterStub(channel)

          reply = await greeter.SayHello(HelloRequest(name='Dr. Strange'))
          print(reply.message)


  if __name__ == '__main__':
      asyncio.run(main())

Server
------

.. code-block:: python3

  import asyncio

  from grpclib.utils import graceful_exit
  from grpclib.server import Server

  # generated by protoc
  from .helloworld_pb2 import HelloReply
  from .helloworld_grpc import GreeterBase


  class Greeter(GreeterBase):

      async def SayHello(self, stream):
          request = await stream.recv_message()
          message = f'Hello, {request.name}!'
          await stream.send_message(HelloReply(message=message))


  async def main(*, host='127.0.0.1', port=50051):
      server = Server([Greeter()])
      # Note: graceful_exit isn't supported in Windows
      with graceful_exit([server]):
          await server.start(host, port)
          print(f'Serving on {host}:{port}')
          await server.wait_closed()


  if __name__ == '__main__':
      asyncio.run(main())

Installation

.. code-block:: console

$ pip3 install grpclib protobuf

Bug fixes and new features are frequently published via release candidates:

.. code-block:: console

$ pip3 install --upgrade --pre grpclib

For the code generation you will also need a protoc compiler, which can be installed with protobuf system package:

.. code-block:: console

$ brew install protobuf # example for macOS users $ protoc --version libprotoc ...

Or you can use protoc compiler from the grpcio-tools Python package:

.. code-block:: console

$ pip3 install grpcio-tools $ python3 -m grpc_tools.protoc --version libprotoc ...

Note: grpcio and grpcio-tools packages are not required in runtime, grpcio-tools package will be used only during code generation.

protoc plugin


In order to use this library you will have to generate special stub files using
plugin provided, which can be used like this:

.. code-block:: console

  $ python3 -m grpc_tools.protoc -I. --python_out=. --grpclib_python_out=. helloworld/helloworld.proto
                                                      ^----- note -----^

This command will generate ``helloworld_pb2.py`` and ``helloworld_grpc.py``
files.

Plugin which implements ``--grpclib_python_out`` option should be available for
the ``protoc`` compiler as the ``protoc-gen-grpclib_python`` executable which
should be installed by ``pip`` into your ``$PATH`` during installation of the
``grpclib`` library.

Changed in v0.3.2: ``--python_grpc_out`` option was renamed into
``--grpclib_python_out``.

Contributing
~~~~~~~~~~~~

* Please submit an issue before working on a Pull Request
* Do not merge/squash/rebase your development branch while you work on a Pull
  Request, use rebase if this is really necessary
* You may use Tox_ in order to test and lint your changes, but it is Ok to rely
  on CI for this matter

.. _gRPC: http://www.grpc.io
.. _hyper-h2: https://github.com/python-hyper/hyper-h2
.. _grpcio: https://pypi.org/project/grpcio/
.. _Tox: https://tox.readthedocs.io/
.. _examples: https://github.com/vmagamedov/grpclib/tree/master/examples
.. |version| image:: https://img.shields.io/pypi/v/grpclib.svg?label=stable&color=blue
.. _version: https://pypi.org/project/grpclib/
.. |license| image:: https://img.shields.io/pypi/l/grpclib.svg?color=blue
.. _license: https://github.com/vmagamedov/grpclib/blob/master/LICENSE.txt
.. |tag| image:: https://img.shields.io/github/tag/vmagamedov/grpclib.svg?label=latest&color=blue
.. _tag: https://pypi.org/project/grpclib/#history
.. |project| image:: https://img.shields.io/badge/vmagamedov%2Fgrpclib-blueviolet.svg?logo=github&color=blue
.. _project: https://github.com/vmagamedov/grpclib
.. |documentation| image:: https://img.shields.io/badge/docs-grpclib.rtfd.io-blue.svg
.. _documentation: https://grpclib.readthedocs.io/en/latest/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].