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
RPCServiceclass 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
registerdecorator. - 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
RPCClientclass fromclient.rpc_client. - Define your client class and initialize the RPC client with the Redis URL and service name.
- Call the function using the
executemethod 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file callite-0.2.10.tar.gz.
File metadata
- Download URL: callite-0.2.10.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da7f3f6008acdea977058dfc9f50b0bab9325ad6601ebcdb87c3d88a77ad58af
|
|
| MD5 |
008fffff0dbad1fb932e6892f7cba668
|
|
| BLAKE2b-256 |
6cfd3d476ed290435ae0ac7db78b17b6568bac5b4eacccdaf4a1bd77cb364a0f
|
Provenance
The following attestation bundles were made for callite-0.2.10.tar.gz:
Publisher:
python-publish.yml on gri-ai/callite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
callite-0.2.10.tar.gz -
Subject digest:
da7f3f6008acdea977058dfc9f50b0bab9325ad6601ebcdb87c3d88a77ad58af - Sigstore transparency entry: 169901491
- Sigstore integration time:
-
Permalink:
gri-ai/callite@a949b97dffd01af93ffde30d7b4a2dfc21001ac2 -
Branch / Tag:
refs/tags/v0.2.10 - Owner: https://github.com/gri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a949b97dffd01af93ffde30d7b4a2dfc21001ac2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file callite-0.2.10-py3-none-any.whl.
File metadata
- Download URL: callite-0.2.10-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16303b802b61fdb30cab1b67c38e71ac5a579e5c8af2e673c027b27e26385904
|
|
| MD5 |
6e06ccec7d70e525b214550d2da37583
|
|
| BLAKE2b-256 |
6edafafe2ef579bf2a8a06743af63b78ccc950015b1ac99473ac4ec022a87f7d
|
Provenance
The following attestation bundles were made for callite-0.2.10-py3-none-any.whl:
Publisher:
python-publish.yml on gri-ai/callite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
callite-0.2.10-py3-none-any.whl -
Subject digest:
16303b802b61fdb30cab1b67c38e71ac5a579e5c8af2e673c027b27e26385904 - Sigstore transparency entry: 169901493
- Sigstore integration time:
-
Permalink:
gri-ai/callite@a949b97dffd01af93ffde30d7b4a2dfc21001ac2 -
Branch / Tag:
refs/tags/v0.2.10 - Owner: https://github.com/gri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a949b97dffd01af93ffde30d7b4a2dfc21001ac2 -
Trigger Event:
push
-
Statement type: