No project description provided
Project description
flow-med
A high-performance, type-safe Mediator pattern implementation for Python 3.13+, built on top of flow-res and injector.
Features
- Result-Driven Development: Built-in support for
flow-resResult types, making error handling explicit and type-safe. - Auto-Registration: Handlers are automatically registered using Python 3.13's
__init_subclass__and generic introspection. - Dependency Injection: Seamless integration with the
injectorlibrary for robust dependency management. - Native Async Support: Designed from the ground up for
asynciowithAwaitableResultsupport for elegant method chaining. - Strict Type Safety: Fully compatible with
pyrightandmypyusing modern Python 3.13 type parameters.
Installation
pip install flow-med
Quick Start
1. Define Request and Result
from flow_res import Result
from flow_med import Request
class GetUserRequest(Request[Result[str, Exception]]):
def __init__(self, user_id: int):
self.user_id = user_id
2. Implement Handler
Handlers are automatically registered when defined. Use @override to ensure correct implementation.
from typing import override
from flow_res import Ok, Result
from flow_med import RequestHandler
class GetUserHandler(RequestHandler[GetUserRequest, Result[str, Exception]]):
@override
async def handle(self, request: GetUserRequest) -> Result[str, Exception]:
# Logic to get user
return Ok(f"User {request.user_id}")
3. Initialize and Send
import asyncio
from injector import Injector
from flow_med import Mediator
async def main():
# Initialize with an Injector
Mediator.initialize(Injector())
# Send request and chain results using flow-res
result = await (
Mediator.send_async(GetUserRequest(user_id=1))
.map(lambda name: f"Hello, {name}!")
.unwrap()
)
print(result) # Hello, User 1!
if __name__ == "__main__":
asyncio.run(main())
Requirements
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flow_med-0.1.0.tar.gz.
File metadata
- Download URL: flow_med-0.1.0.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f747b4e1c4adb4595988fbe78bacf125a15f197eff2f823c82bb2ae2baa57ac
|
|
| MD5 |
d072050e9162c2c8d81636060840ea95
|
|
| BLAKE2b-256 |
a1a5ae0223a8c6259baa582a08b9fdd4b1aff67755ccc570ece2906b3e987440
|
Provenance
The following attestation bundles were made for flow_med-0.1.0.tar.gz:
Publisher:
publish-prod.yml on aiagate/flow-med
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flow_med-0.1.0.tar.gz -
Subject digest:
6f747b4e1c4adb4595988fbe78bacf125a15f197eff2f823c82bb2ae2baa57ac - Sigstore transparency entry: 1285805484
- Sigstore integration time:
-
Permalink:
aiagate/flow-med@034418550976b64d04ea5ca26c023aead8623752 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aiagate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-prod.yml@034418550976b64d04ea5ca26c023aead8623752 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flow_med-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flow_med-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
339cc829c94de0d05c41061cea114b98318a165e38f85bac027998fbd7fb1398
|
|
| MD5 |
9183f26efbf54b193d74d68dd7f94728
|
|
| BLAKE2b-256 |
610d83171fc8a4abda1fd497d0a8e4974da846c82998e343e8ddf19788fb2b34
|
Provenance
The following attestation bundles were made for flow_med-0.1.0-py3-none-any.whl:
Publisher:
publish-prod.yml on aiagate/flow-med
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flow_med-0.1.0-py3-none-any.whl -
Subject digest:
339cc829c94de0d05c41061cea114b98318a165e38f85bac027998fbd7fb1398 - Sigstore transparency entry: 1285805576
- Sigstore integration time:
-
Permalink:
aiagate/flow-med@034418550976b64d04ea5ca26c023aead8623752 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aiagate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-prod.yml@034418550976b64d04ea5ca26c023aead8623752 -
Trigger Event:
push
-
Statement type: