Async connection management for Manaflow services
Project description
Manaflow
Async connection management for Manaflow services. This package provides utilities for managing database connections and other services with dependency injection.
Installation
pip install manaflow
Usage
import asyncio
import manaflow
from manaflow import secrets_manager
# Pre-populate secrets manager with scoped keys
secrets_manager.set_secret("postgres_conn_db_uri", "postgresql://user:pass@localhost/mydb")
secrets_manager.set_secret("redis_conn_cache_uri", "redis://localhost:6379")
# Define connection factories with scoped secrets
@manaflow.connection("postgres_conn_db", secret_keys=["uri"])
async def postgres_factory(uri: str):
# Use your preferred async PostgreSQL driver
return await create_postgres_pool(uri)
@manaflow.connection("redis_conn_cache", secret_keys=["uri"])
async def redis_factory(uri: str):
# Use your preferred async Redis driver
return await create_redis_connection(uri)
# Use connections with dependency injection
async def demo_postgres(db=manaflow.Depends("postgres_conn_db")):
# The connection is automatically retrieved and injected
connection = await db()
# Use the connection
return {"status": "success"}
# Run everything
async def main():
result = await demo_postgres()
print(result)
# Close all connections when done
await manaflow.connection.close_connections()
if __name__ == "__main__":
asyncio.run(main())
Features
- Async connection management with dependency injection
- Secret management for connection credentials
- Support for multiple connection types (PostgreSQL, MySQL, MongoDB, Redis, HTTP, etc.)
- No external dependencies required
License
MIT
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
manaflow-0.1.0.tar.gz
(6.1 kB
view details)
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 manaflow-0.1.0.tar.gz.
File metadata
- Download URL: manaflow-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
632f7cfe62021e644fc282b5102a2eeb568449fc3c5dd3a5ca364787ecd8a62e
|
|
| MD5 |
86211459e5385f618b50106e2416160d
|
|
| BLAKE2b-256 |
d3e4068a3958c84dda4eb981478ae68b45f3984fbae7e543d919a12533d6292d
|
File details
Details for the file manaflow-0.1.0-py3-none-any.whl.
File metadata
- Download URL: manaflow-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93bee6d29e6803ab6c2cc96bf0e63b6b3e0ab24f85af9687e4220f194e3af496
|
|
| MD5 |
917050494015f9d99a7e3ab39bf9936d
|
|
| BLAKE2b-256 |
261feac9d4831f6f168e0b5b7103a84b2a2f0a368bd342974e1dd00c81474173
|