Skip to content
/ rpc Public

Very simple python rabbitmq/pika rpc library

License

Notifications You must be signed in to change notification settings

Mause/rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

efa102b · Feb 27, 2024
Jan 6, 2024
Feb 27, 2024
Oct 7, 2023
Nov 23, 2020
Apr 27, 2021
Dec 25, 2023
May 17, 2022
Feb 27, 2024
Apr 25, 2020
Oct 7, 2023
Jan 6, 2024
Nov 26, 2020
Feb 27, 2024
Oct 7, 2023

Repository files navigation

Mause RPC

A dumb as hell rpc implementation built on rabbitmq

Need to write a server?

from mause_rpc.server import Server

rpc_queue = "rpc.queue"
server = Server(rpc_queue, "rabbitmq://...")


@server.register
def hello(name: str) -> str:
    return "hello " + name


@server.register("divide")
def div(a: int, b: int) -> float:
    if b == 0:
        raise ZeroDivisionError()
    return a / b


if __name__ == "__main__":
    server.serve()

Need a client?

from mause_rpc.client import get_client

rpc_queue = "rpc.queue"
client = get_client(rpc_queue, "rabbitmq://...")


def test_basic_functionality():
    assert client.hello("mark") == "hello mark"
    assert client.divide(5, 2) == 2.5

    with pytest.raises(ZeroDivisionError):
        client.divide(5, 0)

About

Very simple python rabbitmq/pika rpc library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages