Skip to main content

Common utilities for Earnbase services

Project description

Earnbase Common

A comprehensive utility package providing common functionality for Earnbase microservices.

Features

Core Components

  • Configuration Management (config/)

    • YAML-based configuration loading
    • Environment variable support
    • Pydantic settings validation
  • Database Integration (database/)

    • MongoDB async connection management
    • Connection pooling
    • Database operation utilities
  • Error Handling (errors/)

    • Standardized error classes
    • Custom exception handling
    • Error response formatting
  • HTTP Utilities (http/)

    • Request/Response handling
    • HTTP client utilities
    • API response formatting
  • Logging (logging/)

    • Structured logging with structlog
    • Log formatting and configuration
    • Log level management
  • Metrics (metrics/)

    • Prometheus metrics integration
    • Custom metrics collection
    • Monitoring utilities
  • Middleware (middleware/)

    • Request tracking
    • Authentication middleware
    • Cross-cutting concerns
  • Redis Integration (redis/)

    • Async Redis client
    • Connection management
    • Caching utilities
  • Response Handling (responses/)

    • Standardized response models
    • Success/Error response formatting
    • JSON serialization
  • Security (security/)

    • JWT token management
    • Password hashing
    • Cryptographic utilities

Installation

pdm add earnbase-common

Usage

Configuration

from earnbase_common.config import load_config

config = load_config("config.yaml")

Database

from earnbase_common.database import mongodb

await mongodb.connect(url="mongodb://localhost:27017")

Logging

from earnbase_common.logging import get_logger

logger = get_logger(__name__)
logger.info("message", extra={"key": "value"})

Redis

from earnbase_common.redis import redis_client

await redis_client.connect(url="redis://localhost:6379")

Response Models

from earnbase_common.responses import SuccessResponse

response = SuccessResponse(
    success=True,
    message="Operation successful",
    data={"key": "value"}
)

Development

Prerequisites

  • Python 3.9+
  • PDM

Setup

  1. Clone the repository
  2. Install dependencies:
pdm install

Testing

pdm run pytest

Building

pdm build

Version Compatibility

  • Python: >=3.9
  • FastAPI: >=0.104.1
  • Pydantic: >=2.5.2
  • Motor: >=3.3.2

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT

Support

For support, email dev@earnbase.io

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

earnbase_common-0.1.14.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

earnbase_common-0.1.14-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file earnbase_common-0.1.14.tar.gz.

File metadata

  • Download URL: earnbase_common-0.1.14.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.1 CPython/3.10.16 Linux/6.8.0-49-generic

File hashes

Hashes for earnbase_common-0.1.14.tar.gz
Algorithm Hash digest
SHA256 ac55a4b86c7d02223bc1d8f25392486a558e4ccefa98b21081da5e4e2cd4a0d7
MD5 08dfc2ed07a7784cca7da6a55fac30e2
BLAKE2b-256 89e7dc571daed7653e3969610223822ec2861179937aea03d55da69f7d9f33c5

See more details on using hashes here.

File details

Details for the file earnbase_common-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: earnbase_common-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.1 CPython/3.10.16 Linux/6.8.0-49-generic

File hashes

Hashes for earnbase_common-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 be4dad7646d323bf80837c3674d70fcc246c61f37350ec4850e02aaab3226efd
MD5 664e6d5b4afce0262be0ed44059fb7ea
BLAKE2b-256 32caee0802a346d3bf0c3df9c4dbd091bab938c25b1d535e525b9b8bc1111a21

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