Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinysdk-0.4.2.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinysdk-0.4.2-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file tinysdk-0.4.2.tar.gz.

File metadata

  • Download URL: tinysdk-0.4.2.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinysdk-0.4.2.tar.gz
Algorithm Hash digest
SHA256 87ff976c2d98d7f7a9a3df9ee8f0e6e73a1ea0387a2f0c17d3c843c2b05d104a
MD5 f3dba731e23a7dc2658966a40154f531
BLAKE2b-256 51aafe94d30b2c5fc2fc27ebfb133f86e8a143713de987618c7abc79749d0ede

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinysdk-0.4.2.tar.gz:

Publisher: publish.yml on synapzegmbh/TinySDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinysdk-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: tinysdk-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinysdk-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05e79ea6d72838f3d7922a45108e98acab2a7ab7bb78a7ae8bd1ce4b3e56c6fe
MD5 13196f6f13aa5181ca6135c15fcbaafe
BLAKE2b-256 3b08a01f59c6dbd8ffd24852db1ad0d55120621b01ecddff3d81b4c89d9bbad7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinysdk-0.4.2-py3-none-any.whl:

Publisher: publish.yml on synapzegmbh/TinySDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page