Slim Redis RPC implementation
Project description
Callite
callite is a lightweight Remote Procedure Call (RPC) implementation over Redis, designed to facilitate communication between different components of a distributed system. It minimizes dependencies and offers a simple yet effective solution for decoupling complex systems, thus alleviating potential library conflicts.
Setting up Callite
Before using callite, ensure you have a Redis instance running. You can start a Redis server using the default settings or configure it as per your requirements.
Implementing the Server
To implement the Callite server, follow these steps:
- Import the
RPCService
class fromserver.rpc_server
. - Define your main class and initialize the RPC service with the Redis URL and service name.
- Register your functions with the RPC service using the
register
decorator. - Run the RPC service indefinitely.
Here's an example server implementation:
from callite.server import RPCService
class Main:
def __init__(self):
service = "service"
redis_url = "redis://redis:6379/0"
self.rpc_service = RPCService(redis_url, 'my_service')
def run(self):
@self.rpc_service.register
def healthcheck():
return "OK"
@self.rpc_service.register
def foo(paramX, paramY):
// Do something with paramX and paramY
return "OK"
self.rpc_service.run_forever()
if __name__ == "__main__":
Main().run()
Calling the Function from Client
Once the server is set up, you can call functions remotely from the client side. Follow these steps to call functions:
- Import the
RPCClient
class fromclient.rpc_client
. - Define your client class and initialize the RPC client with the Redis URL and service name.
- Call the function using the
execute
method of the RPC client. - Optionally, you can pass arguments and keyword arguments to the function.
Here's an example client implementation:
import time
from callite.client.rpc_client import RPCClient
class Healthcheck():
def __init__(self):
self.r = RPCClient("redis://redis:6379/0", "my_service")
def get_status(self):
status = self.r.execute('healthcheck')
return status
def foo(self. paramX, paramY):
response = self.r.execute('foo', paramX = paramX, paramY = paramY)
return status
You can also pass arguments and keyword arguments to the execute
method as follows:
client = RPCClient('redis://localhost:6379', 'my_service')
...
...
response = client.execute('foo', 1, 2)
This setup allows for efficient communication between components of a distributed system, promoting modularity and scalability.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file callite-0.2.9.tar.gz
.
File metadata
- Download URL: callite-0.2.9.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a00959c4004e6943ba1bdea5a56477cbb938ca9051f1df8971bf85bbe842c5d |
|
MD5 | 3dbe0a4c81750e0c4cad177aff1b1c60 |
|
BLAKE2b-256 | 4ff2e3eb6455b2fd03dcc31eecd997e1d51d620e92210c2b1117084af91c8c89 |
Provenance
The following attestation bundles were made for callite-0.2.9.tar.gz
:
Publisher:
python-publish.yml
on gri-ai/callite
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
callite-0.2.9.tar.gz
- Subject digest:
4a00959c4004e6943ba1bdea5a56477cbb938ca9051f1df8971bf85bbe842c5d
- Sigstore transparency entry: 145891505
- Sigstore integration time:
- Predicate type:
File details
Details for the file callite-0.2.9-py3-none-any.whl
.
File metadata
- Download URL: callite-0.2.9-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d53b3e0efe012cbcacf5563ef91a2bdbb24e223637520edd40a90fe7f7b5353 |
|
MD5 | 014db8961bde6862befd46dfcc7cbb88 |
|
BLAKE2b-256 | 95476d206e986cfbe862a5453a3dca8d3d5e42791ece41b1a1e15d5da68ec528 |
Provenance
The following attestation bundles were made for callite-0.2.9-py3-none-any.whl
:
Publisher:
python-publish.yml
on gri-ai/callite
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
callite-0.2.9-py3-none-any.whl
- Subject digest:
1d53b3e0efe012cbcacf5563ef91a2bdbb24e223637520edd40a90fe7f7b5353
- Sigstore transparency entry: 145891507
- Sigstore integration time:
- Predicate type: