Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raddish

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raddish

Async-native Redis-backed RPC and job queue

  • 0.2.4
  • PyPI
  • Socket score

Maintainers
1

Raddish

Raddish is mix of RPC and job queue backed by Redis. You can launch multiple servers that will accept the same function calls in a round-robin fashion. From the client side you can asynchronously submit jobs and block the execution until they are completed.


Getting started

  1. Implement a server
import asyncio
import logging
import os

from redis.asyncio import Redis
from rich.logging import RichHandler

from raddish import RaddishServer, AsyncWorker

logging.basicConfig(
    level=logging.INFO,
    format="%(message)s",
    datefmt="[%X]",
    handlers=[RichHandler(rich_tracebacks=True)],
)

logger = logging.getLogger("raddish-test")


class TestWorker(AsyncWorker):
    async def setup(self) -> None:
        logger.info("Setting up test worker")

    async def __call__(self, input: dict[str, any]) -> dict[str, any]:
        logger.info(f"Received input: {input}")
        input: int = input["number"]
        input += 1
        await asyncio.sleep(10)
        return {
            "number": input,
        }


async def main() -> None:
    redis_client: Redis = Redis.from_url(
        os.environ.get("REDIS_URL", "redis://localhost:6379")
    )
    server: RaddishServer = RaddishServer(redis_client)
    server.add_worker("add_one", TestWorker())
    await server.start()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

  1. Implement a client
import asyncio
import logging
import os

from redis.asyncio import Redis
from rich.logging import RichHandler

from raddish import AsyncRaddishClient

logging.basicConfig(
    level=logging.INFO,
    format="%(message)s",
    datefmt="[%X]",
    handlers=[RichHandler(rich_tracebacks=True)],
)

logger = logging.getLogger("raddish-test")


async def main() -> None:
    redis_client: Redis = Redis.from_url(
        os.environ.get("REDIS_URL", "redis://localhost:6379")
    )
    client: AsyncRaddishClient = AsyncRaddishClient(redis_client)

    counter: int = 0
    for _ in range(5):
        logger.info(f"Sending input {counter}")
        counter = (await client.call("add_one", {"number": counter}))["number"]
        logger.info(f"Received output {counter}")


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

  1. Launch one or more servers
python server.py
  1. Launch one or more clients
python client.py

Features

  • You can add servers at any time in order to increase capacity
  • Asyncio-native
  • Servers can be located anywhere where there is internet, no need to have public ip - you only need to be able to connect to the redis server

License

Raddish is licensed under Apache License, Version 2.0

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc