Skip to main content

Remote Procedure Call over Redis

This library provides an RPC implementation over Redis.
To forward a request from the client to the service for the execution of the method, Redis Streams is used together with Consumer Groupss to distribute requests.
To forward the result of the method execution from the service to the client, Redis PubSub is used with unique client and request identifiers

Features

  • Transparent forwarding of arguments and return value
  • Supports/forces the use of Python type hints
  • Built-in consistency check client-side with the server-side
  • Supports multiple server-side instances at the same time, balancing via Redis
  • Zeroconf, does not require open ports, addresses, HTTP API implementation, etc. Only Redis.
  • Uses the built-in capabilities of Redis 5.0+ to forwarding in both directions

Installation

pip install rpc-over-redis

Using

First, you need to declare the server-side (service) app:
server.py

import os
from rpc_over_redis.core import RPCOverRedisService

redis_url = os.environ['REDIS_URL']     # REDIS_URL=redis://:password@redis/0

# initializing server-side
r = RPCOverRedisService(
    redis_url,
    'SmartEchoService'
)

@r.register
def echo() -> None:
    print('echo is called')
    pass

r.run_forever()

Then, you need to create a header class with empty methods.
Now you can use it like a regular class. The arguments and the return value will be transparently passed through Redis

import os
from rpc_over_redis.core import RPCOverRedisClient

class SmartEchoService(RPCOverRedisClient):
    def __init__(self, conn_url: str):
        super().__init__(conn_url, self.__class__.__name__, strict_validate_schema=True)

    def echo(self) -> None:
        ...

# initializing client-side
client = SmartEchoService(os.environ['REDIS_URL'])       # REDIS_URL=redis://:password@redis/0

# execute remote methods as local class methods...
client.echo()  # none returned

More examples see here

Additional options

// TODO

Limitations

  • Only built-in types that allow to be converted to json/string should be used as arguments and return values.

Metadata

Release files for rpc-over-redis 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rpc-over-redis 0.0.5
File Size Uploaded
rpc-over-redis-0.0.5.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rpc-over-redis 0.0.5
File Interpreter ABI Platform
rpc_over_redis-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / rpc-over-redis-0.0.5.tar.gz

Download URL rpc-over-redis-0.0.5.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0d05064461e6b08043dc51cb3b6398285021b06cb02be7bf0a4fa41af81ed39b
BLAKE2b-256 checksum
How to use checksums
0942529d3a356ebd35605219b6e35170c052defffbc088d2e8c631895dc23bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release files / rpc_over_redis-0.0.5-py3-none-any.whl

Download URL rpc_over_redis-0.0.5-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e56468a8f3d56de3555095b4de432181981abd7a9d51af48b521e2dc7ebb8d6e
BLAKE2b-256 checksum
How to use checksums
b83fa504f6b62331513685dad9120e4b2fa298fae61de3787ce9a010c0653895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page