aioddd-1.3.8
توضیحات
Async Python DDD utilities library.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aioddd-1.3.8 |
| نام | aioddd |
| نسخه کتابخانه | 1.3.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | ['ticdenis <denisnavarroalcaide@outlook.es>'] |
| نویسنده | - |
| ایمیل نویسنده | ticdenis <denisnavarroalcaide@outlook.es>, yasti4 <adria_4_@hotmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/aioddd/ |
| مجوز | MIT |
# Async Python DDD utilities library
[](https://badge.fury.io/py/aioddd)
[](https://pepy.tech/project/aioddd)
[](https://github.com/aiopy/python-aioddd/actions/workflows/ci.yml)
aioddd is an async Python DDD utilities library.
## Installation
Use the package manager [pip](https://pypi.org/project/aioddd/) to install aioddd.
```bash
pip install aioddd
```
## Documentation
- Visit [aioddd docs](https://aiopy.github.io/python-aioddd/).
## Usage
```python
from asyncio import get_event_loop
from dataclasses import dataclass
from typing import Type
from aioddd import NotFoundError, \
Command, CommandHandler, SimpleCommandBus, \
Query, QueryHandler, OptionalResponse, SimpleQueryBus, Event
_products = []
class ProductStored(Event):
@dataclass
class Attributes:
ref: str
attributes: Attributes
class StoreProductCommand(Command):
def __init__(self, ref: str):
self.ref = ref
class StoreProductCommandHandler(CommandHandler):
def subscribed_to(self) -> Type[Command]:
return StoreProductCommand
async def handle(self, command: StoreProductCommand) -> None:
_products.append(command.ref)
class ProductNotFoundError(NotFoundError):
_code = 'product_not_found'
_title = 'Product not found'
class FindProductQuery(Query):
def __init__(self, ref: str):
self.ref = ref
class FindProductQueryHandler(QueryHandler):
def subscribed_to(self) -> Type[Query]:
return FindProductQuery
async def handle(self, query: FindProductQuery) -> OptionalResponse:
if query.ref != '123':
raise ProductNotFoundError.create(detail={'ref': query.ref})
return {'ref': query.ref}
async def main() -> None:
commands_bus = SimpleCommandBus([StoreProductCommandHandler()])
await commands_bus.dispatch(StoreProductCommand('123'))
query_bus = SimpleQueryBus([FindProductQueryHandler()])
response = await query_bus.ask(FindProductQuery('123'))
print(response)
if __name__ == '__main__':
get_event_loop().run_until_complete(main())
```
## Requirements
- Python >= 3.7
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://github.com/aiopy/python-aioddd/blob/master/LICENSE)
نیازمندی
| مقدار | نام |
|---|---|
| ==0.8.0 | build |
| ==65.3.0 | setuptools |
| ==4.0.1 | twine |
| ==0.37.1 | wheel |
| ==2.19.0 | pre-commit |
| ==2.0.1 | tomli |
| ==0.1.3 | types-backports |
| ==0.10.8 | types-toml |
| ==1.3.0 | mkdocs |
| ==8.2.15 | mkdocs-material |
| ==22.8.0 | black |
| ==5.10.1 | isort |
| ==1.7.4 | bandit |
| ==0.7.2 | liccheck |
| ==0.971 | mypy |
| ==2.15.0 | pylint |
| ==1.5.5 | nest-asyncio |
| ==5.9.2 | psutil |
| ==7.1.3 | pytest |
| ==0.19.0 | pytest-asyncio |
| ==3.0.0 | pytest-cov |
| ==2.5.0 | pytest-xdist |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl aioddd-1.3.8:
pip install aioddd-1.3.8.whl
نصب پکیج tar.gz aioddd-1.3.8:
pip install aioddd-1.3.8.tar.gz