Skip to main content

Official Throome SDK for Python

Project description

Throome Python SDK

Official Python SDK for Throome - Universal Gateway for Modern Applications.

Installation

pip install throome-sdk

Quick Start

from throome import ThroomClient

client = ThroomClient(base_url="http://localhost:9000")

# Check health
health = client.health()
print(f"Gateway status: {health.status}")

# List clusters
clusters = client.list_clusters()
print(f"Found {len(clusters)} clusters")

Features

  • Cluster Management: Create, list, get, and delete clusters
  • Health Monitoring: Check gateway and cluster health
  • Activity Logging: View detailed activity logs
  • Service Operations: Get service info and logs
  • Database Client: Execute SQL queries through the gateway
  • Cache Client: Redis operations (GET, SET, DELETE)
  • Queue Client: Publish messages to Kafka topics
  • Type Hints: Full type annotation support
  • Dataclasses: Clean, Pythonic data structures

Usage Examples

Create a Cluster

from throome import ServiceConfig

services = {
    "redis-1": ServiceConfig(type="redis", port=6379),
    "postgres-1": ServiceConfig(
        type="postgres",
        port=5432,
        username="postgres",
        password="password",
        database="mydb",
    ),
}

response = client.create_cluster(name="my-cluster", services=services)
print(f"Created cluster: {response.cluster_id}")

Cache Operations

cluster = client.cluster("cluster-id")
cache = cluster.cache()

# Set value with TTL
cache.set("user:123", "John Doe", expiration=60)

# Get value
value = cache.get("user:123")

# Delete value
cache.delete("user:123")

Database Operations

db = cluster.db()

# Execute statement
db.execute("CREATE TABLE users (id SERIAL, name VARCHAR(100))")

# Query rows
rows = db.query("SELECT * FROM users WHERE id = $1", 123)

# Query single row
row = db.query_row("SELECT * FROM users WHERE id = $1", 123)

Get Service Logs

from throome import LogOptions

service = cluster.service("redis-1")

# Get last 100 lines
logs = service.get_logs(options=LogOptions(tail=100, timestamps=True))

Monitor Activity

from throome import ActivityFilters

# Get cluster activity logs
logs = cluster.get_activity(filters=ActivityFilters(limit=50))

for log in logs:
    timestamp = log.timestamp.strftime("%H:%M:%S")
    print(f"[{timestamp}] {log.service_name}.{log.operation}: {log.command} ({log.status})")

Complete Example

See examples/main.py for a complete working example.

API Reference

ThroomClient

  • health(): Check gateway health
  • list_clusters(): List all clusters
  • get_cluster(cluster_id): Get cluster details
  • create_cluster(name, services): Create new cluster
  • delete_cluster(cluster_id): Delete cluster
  • get_activity(filters=None): Get global activity logs
  • cluster(cluster_id): Get cluster client

ClusterClient

  • health(): Check cluster health
  • metrics(): Get cluster metrics
  • get_activity(filters=None): Get cluster activity logs
  • service(service_name): Get service client
  • db(): Get database client
  • cache(): Get cache client
  • queue(): Get queue client

ServiceClient

  • get_info(): Get service information
  • get_logs(options=None): Get Docker container logs
  • get_activity(filters=None): Get service activity logs

Error Handling

from throome import ThroomAPIError, ThroomConnectionError

try:
    cluster = client.get_cluster("invalid-id")
except ThroomAPIError as e:
    print(f"API Error ({e.status_code}): {e}")
except ThroomConnectionError as e:
    print(f"Connection Error: {e}")

Type Hints

The SDK includes full type annotations for better IDE support:

from throome import (
    Cluster,
    Service,
    ServiceConfig,
    CreateClusterRequest,
    HealthResponse,
    ActivityLog,
    # ... and more
)

Requirements

  • Python 3.8 or higher
  • requests >= 2.31.0

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

throome_sdk-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

throome_sdk-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file throome_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: throome_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for throome_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d29be6b62ac90a78f5a360283b463a7466e47cf858eafa7766d2d14660ed31a5
MD5 ce923089bf632fea04aa8a865ae53ced
BLAKE2b-256 464bd6d1544bd7be9efa1ce4a9f4c2f0b679ebbe91c2ba8afda77d0619f3501f

See more details on using hashes here.

File details

Details for the file throome_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: throome_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for throome_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf41997165490f42934d8e593abc3f478a1ac658044af1b8e7d72d2515495af6
MD5 804037582d75fdc074c95b24f39370ce
BLAKE2b-256 865987b7c52ead9bfb062a7452a5f55c4e0f07abe4434861189f8c24c4d64a8f

See more details on using hashes here.

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