Skip to main content

Redis RPC server for microservices

Project description

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.

Project details


Download files

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

Source Distribution

redispubsub-0.0.7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

redispubsub-0.0.7-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file redispubsub-0.0.7.tar.gz.

File metadata

  • Download URL: redispubsub-0.0.7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for redispubsub-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9b6cf9b5a3b0dac26a768ea12b2cbe52fb4ff5c4f93d66a6b266bab2840d1390
MD5 48834dad8957a40ef4177bb219f109cd
BLAKE2b-256 defe976cf46e2403310821c57ba5fd936088d8fac1fa2ffa7a33f0faafeb38e8

See more details on using hashes here.

File details

Details for the file redispubsub-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: redispubsub-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for redispubsub-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 782defbeb77419abaf5eb3bb8f876a32e3bee96197a7bdadf31282540351f2ad
MD5 1d17cf81ec39171536850ec7b2368c6e
BLAKE2b-256 e9fc597780dff83407ef52dda4cd3432bfe2d1ecada5ce032b213f2ac3739704

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