Mediator implementation in Python
Project description
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())
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
mediatpy-0.2.1.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file mediatpy-0.2.1.tar.gz
.
File metadata
- Download URL: mediatpy-0.2.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.8 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f926643849abcac54b07dc8f33c95a4d41fcd705aec80d6d11c70325ddf9d4c7 |
|
MD5 | 8e05e97e2a19c5c0b8beb5b233958de8 |
|
BLAKE2b-256 | e27fc0b1c19ac3f53b5f897e5f8176679ec12ba0ba518531bf1e0cf98068ac42 |
File details
Details for the file mediatpy-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: mediatpy-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.8 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e88a8d04d77f49dc2839963b9cadad8868837fdad1bb547639cb54fffac41bc |
|
MD5 | 8f37ac51f98cb1af32474199b45a9cd5 |
|
BLAKE2b-256 | 069e679605a76a0fcf769b37ef1774f620cce0b650d50bea907097ba2e6e11ad |