Forge your application registries.
Project description
Tamahagane
Forge your application registries.
Tamahagane is a library designed for constructing application registries, the essential foundation for building decoupled software architectures and enabling unit testing on application handlers.
Motivation
Tamahagane essentially serves as a modern alternative to Venusian, fulfilling the same core functionality.
The decision to create a new library stems from Venusian's limitations: it was originally built for Python 2, relies heavily on dynamic behavior, and lacks type support.
Tamahagane reuse the same vocabular, a Scanner and an attach function, but the API is not fully compatible, in order to get a simpler version.
Usage
To use Tamahagane you need to create a registries class that hold all registries your app may load. The definition of the registry is free and depends of the usage.
from dataclasses import dataclass
@dataclass
class Registries:
app_registry: ...
After what, the registries is filled out using the scan of the application code.
import tamahagane as th
scanner = th.Scanner[Registries](Registries(app_registry=...))
scanner.scan("app.service_handlers")
At this time, the app.service_handlers is a module, or a package containing
submodules, that will be recursibely loaded. It contains decorated function,
where the decorator has been created in the application code to create the
callback.
from collections.abc import Callable
from typing import Any
import tamahagane as th
CommandHandler = Callable[..., Any]
def command_handler(wrapped: CommandHandler) -> CommandHandler:
def callback(registries: Registries) -> None:
registries.app_registry.do_something_with(wrapped, ...)
th.attach(callback, category="app_registry")
return wrapped
Now, you have a command_handler decorator that can be used an be filled out an application registry with the decorated method.
@command_handler
def handle_stuff(...):
...
handle_stuff is unmodified by its decorator and is purely unit testable. No overhead.
Installation
Tamahagane is available on PyPI
So you can installing using your favorite packaging tool, mine is uv:
uv add tamahagane
See also
- Documentation - https://mardiros.github.io/tamahagane/
- Venusian - https://docs.pylonsproject.org/projects/venusian/en/
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
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 tamahagane-0.3.0.tar.gz.
File metadata
- Download URL: tamahagane-0.3.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
defbf853dfeeaecefaff6203d60da3549fcfc6cd1550def38cdf136611c2ab54
|
|
| MD5 |
0467f0d7d905f29bc6e9f7ac834239df
|
|
| BLAKE2b-256 |
143fbce335c7a117aeb83cb6644431d4ddd48dc97cbcd5bd2655200dff8f6adf
|
File details
Details for the file tamahagane-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tamahagane-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a90cd36ee6160640bd23de025a5f4465bc3b73c19453af7b8ab0593dc4ffded
|
|
| MD5 |
49deb55d6e5233b77dd2cdf83db777a3
|
|
| BLAKE2b-256 |
926c8152d3f97e51d438bcc0bc42adf23fc8dad13331658779089d05352b079c
|