redis-pub-sub
Redis RPC with PubSub simple lightweight
Getting Started
Install Redis rpc
pip install redispubsub
Server example
import os
from redisrpc import RedisRPC
# Add REDIS_URI application enviroment variable
os.environ.setdefault("REDIS_URI", "redis://localhost:6379/0")
rpc = RedisRPC("channel_name") # rename what you want
# event lists
def calc_square(response): # `response` is a sender data
power_of_number = response**2
return power_of_number # sent to client
def calc_cube(response): # `response` is a sender data
cube_of_number = response**3
return cube_of_number # sent to client
rpc.register(calc_square, "square") # event name default function name
rpc.register(calc_cube, "cube")
rpc.listen()
Client interface
import os
from redisrpc import RedisRPC
# Add REDIS_URI application enviroment
os.environ.setdefault("REDIS_URI", "redis://localhost:6379/0")
rpc = RedisRPC("channel_name") # channel name must be same as server
square = rpc.send("square", 5) # send data to spesific event
cube = rpc.send("cube", 3)
# response from server handlers
print(square) # 25
print(cube) # 27
Contributing
Fell free to open issue and send pull request.
Metadata
Release files for redispubsub 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| redispubsub-0.0.7.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| redispubsub-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / redispubsub-0.0.7.tar.gz
| Download URL | redispubsub-0.0.7.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b6cf9b5a3b0dac26a768ea12b2cbe52fb4ff5c4f93d66a6b266bab2840d1390
|
|
BLAKE2b-256 checksum How to use checksums |
defe976cf46e2403310821c57ba5fd936088d8fac1fa2ffa7a33f0faafeb38e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18
|
Release files / redispubsub-0.0.7-py3-none-any.whl
| Download URL | redispubsub-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
782defbeb77419abaf5eb3bb8f876a32e3bee96197a7bdadf31282540351f2ad
|
|
BLAKE2b-256 checksum How to use checksums |
e9fc597780dff83407ef52dda4cd3432bfe2d1ecada5ce032b213f2ac3739704
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18
|