kaiju-app - application and service base classes. They can be used as building blocks for various asyncio server applications. The library provides base classes, configuration loader and application builder and service dependency resolution mechanisms.
Installation
With pip and python 3.12+:
pip3 install kaiju-app
How to use
See the user guide for more info.
Create a service with custom methods, initialization and de-initialization.
from kaiju_app import Service
class CacheService(Service):
def __init__(self, host: str, port: int, password: str):
...
async def init(self):
self._transport = await self._initialize_transport()
async def close(self):
self._transport.close()
async def load_cache(self):
...
Create a loader and register your service class there.
from kaiju_app import ApplicationLoader
loader = ApplicationLoader()
loader.service_classes['CacheService'] = CacheService
Load your configuration using a configurator and create an application with your services in it. You may use JSON or YAML file loader here instead of implementing the whole config in Python.
from kaiju_app import Configurator, ProjectConfig, AppConfig, ServiceConfig
example_config = ProjectConfig(
packages=[],
logging={},
app=AppConfig(
name='my_app',
env='dev',
services=[
ServiceConfig(
cls='CacheService',
settings={
'host': '[cache_host]',
'port': '[cache_port]',
'password': '[cache_password]'
}
)
]
)
)
example_env = {
'cache_host': 'localhost',
'cache_port': 6379,
'cache_password': 'qwerty'
}
configurator = Configurator()
config = configurator.create_configuration([example_config], [example_env])
The idea behind configuration is that it split on two types of files: config (template) files and env files. Config
files are structured and must obey ProjectConfig special config format. Env files are flat and used to copy values
from, so env file may be a simple plain JSON or a text file or a set of environment variables. You can use any number
of template files and env files in your config - they will be merged.
The configurator uses template-dict to fill the templates.
Next you can pass the resulting config to the AppLoader and create an application which can be run in an asyncio loop.
The run_app function allows you to run the app forever in an asyncio loop until a ctrl+C signal is received.
from kaiju_app import run_app
app = loader.create_all(config)
run_app(app)
Metadata
Release files for kaiju-app 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kaiju_app-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for kaiju_app-0.1.5-py3-none-any.whl |
Release files / kaiju_app-0.1.5-py3-none-any.whl
| Download URL | kaiju_app-0.1.5-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6218bf26117ddfa7500c32213d2073653ab1a88bc6358826a40dd1418abe9de4
|
|
BLAKE2b-256 checksum How to use checksums |
92d736d2dda3b5a289f815d014936c2a5b11ec12e6b794e9551d1ed8fce0fb1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for kaiju-app 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.