Skip to main content

An easy to use rpc framework for enabling fast inter-process, inter-host communication

Project description

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 PyPI version

Documentation

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, within json serializable constraints

Quick Start

$ virtualenv -p python3.7 easy-rpc-env

$ source easy-rpc-env/bin/activate

(easy-rpc-env)$ pip install easyrpc

Basic Usage:

# server.py
from fastapi import FastAPI
from easyrpc.server import EasyRpcServer

server = 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]}

# client.py
import asyncio
from easyrpc.proxy import EasyRpcProxy

async 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

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

easyrpc-0.245-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file easyrpc-0.245-py3-none-any.whl.

File metadata

  • Download URL: easyrpc-0.245-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for easyrpc-0.245-py3-none-any.whl
Algorithm Hash digest
SHA256 db29fb5f214e705d6630e411bcb9156e07c079d2b221233024824a2499f9148f
MD5 72fffa6019b9bf7ba80b8c5a6bf435eb
BLAKE2b-256 b5d9b073fd0b3cdc1bbf439cd52b68d6919000af30d8084ea79961b39d7447ad

See more details on using hashes here.

Supported by

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