Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codemation/easyrpc
An easy to use rpc framework for enabling fast inter-process, inter-container, or inter-host communication
https://github.com/codemation/easyrpc
asyncio distributed-systems fastapi rpc websockets
Last synced: 3 months ago
JSON representation
An easy to use rpc framework for enabling fast inter-process, inter-container, or inter-host communication
- Host: GitHub
- URL: https://github.com/codemation/easyrpc
- Owner: codemation
- License: mit
- Created: 2020-10-14T12:49:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-01T22:05:21.000Z (about 2 years ago)
- Last Synced: 2024-10-12T18:59:27.812Z (4 months ago)
- Topics: asyncio, distributed-systems, fastapi, rpc, websockets
- Language: Python
- Homepage:
- Size: 755 KB
- Stars: 63
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.MD
Awesome Lists containing this project
README
![](./docs/images/logo.png)
An easy to use rpc framework for enabling fast inter-process, inter-container, or inter-host communication
Easily share functions between hosts, processes, containers without the complexity of defining non-native python types or proxy modules.
[![Documentation Status](https://readthedocs.org/projects/easyrpc/badge/?version=latest)](https://easyrpc.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/easyrpc.svg)](https://pypi.org/project/easyrpc/)
## Documentation
[easyrpc.readthedocs.io](https://easyrpc.readthedocs.io)## Key Features
- No predefined proxy functions at the remote endpoints
- Easily group and share functons among hosts / processes using Namespaces / Namespace Groups
- Proxy functions parameters are validated as if defined locally.
- Optional: pre-flight encyrption
- No strict RPC message structure / size limit
- Flexible parameter types within pickable constraint## Quick Start
```bash
$ virtualenv -p python3.7 easy-rpc-env$ source easy-rpc-env/bin/activate
(easy-rpc-env)$ pip install easyrpc
```## Basic Usage:
```python
# server.py
from fastapi import FastAPI
from easyrpc.server import EasyRpcServerserver = FastAPI()
ws_server_a = EasyRpcServer(server, '/ws/server_a', server_secret='abcd1234')
@ws_server_a.origin(namespace='public')
def good_func_a(a, b, c):
print(f"good_func_a {a} {b} {c}")
return {"good_func_a": [a, b, c]}
```
```python
# client.py
import asyncio
from easyrpc.proxy import EasyRpcProxyasync def main():
proxy = await EasyRpcProxy.create(
'0.0.0.0',
8090,
'/ws/server_a',
server_secret='abcd1234',
'namespace='public'
)good_func_a = proxy['good_func_a']
result = await good_func_a(1, 5, 7)
print(result)asyncio.run(main())
```## Recipes
See other usage examples in [Recipes](https://github.com/codemation/easyrpc/tree/main/recipes)
- [basic](https://github.com/codemation/easyrpc/tree/main/recipes/basic)
- [clusters](https://github.com/codemation/easyrpc/tree/main/recipes/clusters)
- [FastAPI-Shared-Database](https://github.com/codemation/easyrpc/tree/main/recipes/fastapi/shared_database)
- [Generators](https://github.com/codemation/easyrpc/tree/main/recipes/generators)## Supported Functions Features
- async def & def
- async generators & generators
- *args, **kwargs
- positional & default parmeters
- TODO - type annotations## Common Use Cases
- State sharing among forked workers
- Shared Database connections / cache
- Shared Queues
- Worker Pooling - Easy centralization for workers and distribution of work.
- Function Chaining