Skip to content

panicoenlaxbox/mediatpy

Repository files navigation

pre-commit Code style: black Imports: isort Checked with mypy security: bandit Upload Python Package Coverage Status Documentation Status PyPI version

Introduction

This library is a port of Mediatr in Python.

For more information and usage instructions, see the documentation.

Usage

pip install mediatpy

import asyncio

from mediatpy import Request, RequestHandler, Mediator


class MyResponse:
    pass


class MyRequest(Request[MyResponse]):
    pass


mediator = Mediator()


@mediator.request_handler
class MyRequestHandler(RequestHandler[MyRequest, MyResponse]):
    async def handle(self, request: MyRequest) -> MyResponse:
        return MyResponse()


async def main():
    request = MyRequest()
    response = await mediator.send(request)
    assert isinstance(response, MyResponse)


if __name__ == '__main__':
    asyncio.run(main())

About

Mediator implementation in Python

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages