Skip to main content

Shared utilities and models for TL;DR.tv platform

Project description

Common Module

Shared utilities and models for the TL;DR.tv platform.

Structure

common/
├── src/common/
│   ├── core/          # Core functionality (config, exceptions, dependencies)
│   ├── dao/           # Data Access Objects
│   ├── database/      # Database connectivity
│   ├── logging/       # Logging configuration
│   ├── message/       # Message queue models
│   ├── models/        # Domain models
│   ├── platform/      # Platform-specific APIs (Twitch, Kick)
│   └── utils/         # Utility functions
└── tests/
    ├── unit/          # Unit tests
    └── integration/   # Integration tests

Installation

The common module is part of the uv workspace and is automatically available to other services.

For development:

uv pip install -e common

Usage

Data Access Objects (DAOs)

from common.dao import UserDAO, StreamDAO, ClipDAO
from common.database import Db, DBConfig

# Initialize database
db = Db(DBConfig())

# Create DAOs
user_dao = UserDAO(db)
stream_dao = StreamDAO(db)
clip_dao = ClipDAO(db)

Platform APIs

from common.platform.twitch import TwitchApi, TwitchApiConfig
from common.platform.kick import KickApi, KickApiConfig

# Initialize APIs
twitch_api = TwitchApi(config=TwitchApiConfig())
kick_api = KickApi(config=KickApiConfig())

Message Models

from common.message import StreamOnlineMessage, StreamOfflineMessage

# Create messages for RabbitMQ
message = StreamOnlineMessage(
    stream_id="12345",
    user_id=67890,
    platform="twitch",
    started_at=datetime.now()
)

Exception Handling

from common.core.exceptions import (
    DatabaseError,
    TwitchError,
    KickError,
    ValidationError,
    RateLimitError
)

try:
    # Database operation
    user = await user_dao.get_user_by_id(user_id)
except DatabaseError as e:
    logger.error(f"Database error: {e}")

Testing

Run all tests:

uv run pytest common/tests/

Run unit tests only:

uv run pytest common/tests/unit/

Run integration tests:

uv run pytest common/tests/integration/

Type Checking

The module includes type information (py.typed). Run type checking with:

uv run ty check common/

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

tldr_common-0.1.8.tar.gz (115.9 kB view details)

Uploaded Source

Built Distribution

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

tldr_common-0.1.8-py3-none-any.whl (141.9 kB view details)

Uploaded Python 3

File details

Details for the file tldr_common-0.1.8.tar.gz.

File metadata

  • Download URL: tldr_common-0.1.8.tar.gz
  • Upload date:
  • Size: 115.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tldr_common-0.1.8.tar.gz
Algorithm Hash digest
SHA256 5e412d55b55d636a1e11f6cf1b6bbbe8188b022b99b1ca4c60810b6a5ca0e03d
MD5 475d7bebbce2e2c833039a00c1c83c3d
BLAKE2b-256 1b63a5cb3af927be9f9d9f638cc2e499686f3a34997a382e46e8c8653f041837

See more details on using hashes here.

File details

Details for the file tldr_common-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: tldr_common-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 141.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tldr_common-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0a93dbd7cccab8e4532db54e4dc3096d8cc439ed4fb3a59ec48655c637e53966
MD5 9386751e39b13ff7e4084652eb7ee55f
BLAKE2b-256 6663c9b94b8daac8bd21b95634e9aaf3f56d346150b7ad320d66475d388c9b43

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