All Projects → standy66 → Purerpc

standy66 / Purerpc

Licence: apache-2.0
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio

Programming Languages

python
139335 projects - #7 most used programming language
cpython
15 projects
pypy
12 projects

Projects that are alternatives of or similar to Purerpc

zero
Zero: A simple, fast, high performance and low latency Python framework (RPC + PubSub) for building microservices or distributed servers
Stars: ✭ 296 (+136.8%)
Mutual labels:  rpc, asyncio, rpc-framework
asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+23.2%)
Mutual labels:  asynchronous, pypi, asyncio
duckpy
A simple Python library for searching on DuckDuckGo.
Stars: ✭ 20 (-84%)
Mutual labels:  asynchronous, pypi, asyncio
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 (+2613.6%)
Mutual labels:  grpc, rpc, rpc-framework
Hprose Delphi
Hprose is a cross-language RPC. This project is Hprose 2.0 for Delphi and FreePascal
Stars: ✭ 100 (-20%)
Mutual labels:  rpc, rpc-framework
Rpc.py
A fast and powerful RPC framework based on ASGI/WSGI.
Stars: ✭ 98 (-21.6%)
Mutual labels:  rpc, rpc-framework
Whatsmars
Java生态研究(Spring Boot + Redis + Dubbo + RocketMQ + Elasticsearch)🔥🔥🔥🔥🔥
Stars: ✭ 1,389 (+1011.2%)
Mutual labels:  rpc, rpc-framework
Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (-12%)
Mutual labels:  asynchronous, networking
Easyrpc
EasyRpc is a simple, high-performance, easy-to-use RPC framework based on Netty, ZooKeeper and ProtoStuff.
Stars: ✭ 79 (-36.8%)
Mutual labels:  rpc, rpc-framework
Backoff
Python library providing function decorators for configurable backoff and retry
Stars: ✭ 1,670 (+1236%)
Mutual labels:  asyncio, asynchronous
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-10.4%)
Mutual labels:  asyncio, asynchronous
Pool
General Purpose Connection Pool for GRPC,RPC,TCP Sevice Cluster
Stars: ✭ 98 (-21.6%)
Mutual labels:  grpc, rpc
Gotree
Gotree is a vertically distributed framework. Gotree's goal is to easily develop distributed services and liberate the mental burden of developers.
Stars: ✭ 91 (-27.2%)
Mutual labels:  rpc, rpc-framework
Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+997.6%)
Mutual labels:  rpc, rpc-framework
Docker Cloud Platform
使用Docker构建云平台,Docker云平台系列共三讲,Docker基础、Docker进阶、基于Docker的云平台方案。OpenStack+Docker+RestAPI+OAuth/HMAC+RabbitMQ/ZMQ+OpenResty/HAProxy/Nginx/APIGateway+Bootstrap/AngularJS+Ansible+K8S/Mesos/Marathon构建/探索微服务最佳实践。
Stars: ✭ 86 (-31.2%)
Mutual labels:  grpc, rpc
Zanphp
PHP开发面向C10K+的高并发SOA服务 和RPC服务首选框架
Stars: ✭ 1,451 (+1060.8%)
Mutual labels:  rpc, asyncio
Edgedb Python
EdgeDB Python Driver
Stars: ✭ 113 (-9.6%)
Mutual labels:  asyncio, asynchronous
Gorums
Gorums simplify fault-tolerant quorum-based protocols
Stars: ✭ 113 (-9.6%)
Mutual labels:  grpc, rpc-framework
Jrpc
JSON-RPC implementation in C++17
Stars: ✭ 113 (-9.6%)
Mutual labels:  rpc, rpc-framework
Tinvest
Тинькофф Инвестиции, tinkoff, python, aiohttp, requests, pydantic
Stars: ✭ 115 (-8%)
Mutual labels:  asyncio, pypi

purerpc

Build Status PyPI version Downloads

Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio (achieved with anyio compatibility layer).

Requirements

  • CPython >= 3.5
  • PyPy >= 3.5

Installation

Latest PyPI version:

pip install purerpc

Latest development version:

pip install git+https://github.com/standy66/purerpc.git

By default purerpc uses asyncio event loop, if you want to use uvloop, curio or trio, please install them manually.

protoc plugin

purerpc adds protoc-gen-purerpc plugin for protoc to your PATH enviroment variable so you can use it to generate service definition and stubs:

protoc --purerpc_out=. --python_out=. -I. greeter.proto

or, if you installed grpcio_tools Python package:

python -m grpc_tools.protoc --purerpc_out=. --python_out=. -I. greeter.proto

Usage

NOTE: greeter_grpc module is generated by purerpc's protoc-gen-purerpc plugin.

Below are the examples for Python 3.6 and above which introduced asynchronous generators as a language concept. For Python 3.5, where native asynchronous generators are not supported, you can use async_generator library for this purpose. Just mark yielding coroutines with @async_generator decorator and use await yield_(value) and await yield_from_(async_iterable) instead of yield.

Server

from greeter_pb2 import HelloRequest, HelloReply
from greeter_grpc import GreeterServicer
from purerpc import Server


class Greeter(GreeterServicer):
    async def SayHello(self, message):
        return HelloReply(message="Hello, " + message.name)

    async def SayHelloToMany(self, input_messages):
        async for message in input_messages:
            yield HelloReply(message=f"Hello, {message.name}")


server = Server(50055)
server.add_service(Greeter().service)
server.serve(backend="asyncio")  # backend can also be one of: "uvloop", "curio", "trio"

Client

import anyio
import purerpc
from greeter_pb2 import HelloRequest, HelloReply
from greeter_grpc import GreeterStub


async def gen():
    for i in range(5):
        yield HelloRequest(name=str(i))


async def main():
    async with purerpc.insecure_channel("localhost", 50055) as channel:
        stub = GreeterStub(channel)
        reply = await stub.SayHello(HelloRequest(name="World"))
        print(reply.message)

        async for reply in stub.SayHelloToMany(gen()):
            print(reply.message)


if __name__ == "__main__":
    anyio.run(main, backend="asyncio")  # backend can also be one of: "uvloop", "curio", "trio"

You can mix server and client code, for example make a server that requests something using purerpc from another gRPC server, etc.

More examples in misc/ folder

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].