Shared services for TinyAI microservices platform
Project description
TinySDK
Shared service clients for the TinyAI microservices platform — MongoDB, MinIO, RabbitMQ, and structured logging with a consistent interface.
Installation
pip install tinysdk
Quick Start
from tinysdk import TinyDBService, TinyStorageService, TinyMessageService, TinyMessageServiceSync, TinyLogger
# MongoDB
db = TinyDBService()
doc_id = db.create("users", {"name": "John", "email": "john@example.com"})
users = db.read("users", filter={"name": "John"})
count = db.update("users", {"name": "John"}, {"$set": {"active": True}})
count = db.delete("users", {"name": "John"})
exists = db.exists("users", {"email": "john@example.com"})
ids = db.create_multiple("users", [{"name": "Alice"}, {"name": "Bob"}])
db.close()
# MinIO / S3
storage = TinyStorageService()
storage.upload_file("my-bucket", "file.txt", buffer) # file_size auto-detected
storage.upload_file("my-bucket", "file.txt", buffer, 1024) # or pass explicitly
file_buffer, name = storage.download_file("my-bucket", "file.txt")
storage.upload_folder("my-bucket", "/local/folder")
storage.download_folder("my-bucket", "folder-name", "/local/dest")
storage.close()
# RabbitMQ (async, event-driven)
def handler(msg: dict):
print(msg)
svc = TinyMessageService(queue_settings=[("my-queue", handler)])
svc.publish("my-queue", {"task": "run"})
svc.run() # blocks, starts IOLoop
# RabbitMQ (sync, blocking)
with TinyMessageServiceSync() as svc:
svc.publish("my-queue", {"task": "run"})
# Logger
logger = TinyLogger()
logger.log("something happened", level="INFO", context={"key": "value"})
logger.start_heartbeat() # emits periodic HEARTBEAT events
logger.stop_heartbeat() # clean shutdown
doc_logger = logger.for_document("doc-id-123")
doc_logger.log("processing started")
Configuration
All clients read credentials from environment variables.
| Service | Variable | Example |
|---|---|---|
| MongoDB | DB_LINK |
mongodb://mongo:27017 |
| MongoDB | DB_NAME |
tinyDatabase |
| MinIO | MINIO_ENDPOINT |
minio:9000 |
| MinIO | MINIO_ACCESSKEY |
minioadmin |
| MinIO | MINIO_SECRETKEY |
minioadmin |
| RabbitMQ | RABBITMQ_HOST |
rabbitmq |
| RabbitMQ | RABBITMQ_PORT |
5672 |
| RabbitMQ | RABBITMQ_USER |
guest |
| RabbitMQ | RABBITMQ_PASS |
guest |
| Logger | SERVICE_NAME |
my-service |
| Logger | CLUSTER |
prod |
| Logger | NAMESPACE |
default |
| Logger | LOG_LEVEL |
INFO |
| Logger | HEARTBEAT_INTERVAL |
30 |
Credentials can also be passed directly as constructor arguments.
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
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 tinysdk-0.4.0.tar.gz.
File metadata
- Download URL: tinysdk-0.4.0.tar.gz
- Upload date:
- Size: 34.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4499cb3217635297eb305cafca77632ef48ee48e9b54f25db7cecc25e763fce2
|
|
| MD5 |
4e945e166146d4a43e5ad30962ddf987
|
|
| BLAKE2b-256 |
6f548eaa8455a51cc5172e20e3e2d950009fdafb4e80194a55085c70da9a03b3
|
Provenance
The following attestation bundles were made for tinysdk-0.4.0.tar.gz:
Publisher:
publish.yml on synapzegmbh/TinySDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tinysdk-0.4.0.tar.gz -
Subject digest:
4499cb3217635297eb305cafca77632ef48ee48e9b54f25db7cecc25e763fce2 - Sigstore transparency entry: 1247140549
- Sigstore integration time:
-
Permalink:
synapzegmbh/TinySDK@9892b23daae60f322f273e571fbb50f572019c27 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/synapzegmbh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9892b23daae60f322f273e571fbb50f572019c27 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tinysdk-0.4.0-py3-none-any.whl.
File metadata
- Download URL: tinysdk-0.4.0-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a364b761af4b3a772c18635593866c17013765f422b53bb7ce1a79a1e7fef05
|
|
| MD5 |
82e2117feeebf9741a3103ec5a1ae946
|
|
| BLAKE2b-256 |
e791345dbce11c02c9bc74d323cdd55be8f8fb7132fe10ec1eeffc48ba1a0950
|
Provenance
The following attestation bundles were made for tinysdk-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on synapzegmbh/TinySDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tinysdk-0.4.0-py3-none-any.whl -
Subject digest:
9a364b761af4b3a772c18635593866c17013765f422b53bb7ce1a79a1e7fef05 - Sigstore transparency entry: 1247140553
- Sigstore integration time:
-
Permalink:
synapzegmbh/TinySDK@9892b23daae60f322f273e571fbb50f572019c27 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/synapzegmbh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9892b23daae60f322f273e571fbb50f572019c27 -
Trigger Event:
push
-
Statement type: