Anywise let you write your application anywise
Project description
Anywise
Anywise is a framework designed to decouple the business logic of your application from its infrastructure, enabling you to use the same code to handle messages from various sources such as web APIs, message queues, AWS Lambda, and more.
Despite being inspired by Hexagonal Architecture and Event-Driven Architecture, Anywise does not bind itself to any specific purpose.
Source Code: https://github.com/raceychan/anywise
Documentation: On its way here...
Install
pip install anywise
Quck Start
Let start with defining messages:
from anywise import Anywise, MessageRegistry, use
class UserCommand: ...
class CreateUser(UserCommand): ...
class UserEvent: ...
class UserCreated(UserEvent): ...
Next step, Register command handler and event listeners.
Function-based handler/listener
registry = MessageRegistry(command_base=UserCommand, event_base=UserEvent)
@registry
async def create_user(
command: CreateUser,
anywise: Anywise,
service: UserService = use(user_service_factory)
):
await users.signup(command.username, command.user_email)
await anywise.publish(UserCreated(command.username, command.user_email))
@registry
async def notify_user(event: UserCreated, service: EmailSender):
await service.send_greeting(command.user_email)
# you can also menually register many handler at once
registry.register_all(create_user, notify_user)
Example usage with fastapi
from anywise import Anywise
from anywise.integration.fastapi import FastWise
@app.post("/users")
async def signup(command: CreateUser, anywise: FastWise) -> User:
return await anywise.send(command)
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 anywise-0.1.6.tar.gz.
File metadata
- Download URL: anywise-0.1.6.tar.gz
- Upload date:
- Size: 83.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffb5bac4b87ff8165d4e35057fdd60cc21654ed8d18a0a2360bf94bcad1200d0
|
|
| MD5 |
f08997859f63bb1ea7ab60ba8f16470e
|
|
| BLAKE2b-256 |
c719cac6f5f3dca8c75469f68e9b6030b99524d0eee6b281ee3fc01d06eb806f
|
File details
Details for the file anywise-0.1.6-py3-none-any.whl.
File metadata
- Download URL: anywise-0.1.6-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04dac12f66cfccbf74e832e9389086d6acc673b2f62144c0d6e5e2a62e9c361e
|
|
| MD5 |
0388009b45fe33f5aec0715a0cf8f3cc
|
|
| BLAKE2b-256 |
857f94a99cdf92f490e87f1706495d352377bf4e009fd3140ff94f3b89f6c4f1
|