Skip to main content

Modular Application (Plugin System) API

Project description

DSkity

Build Release PyPI License Issues

A small, modular Python framework for building services with pluggable transports and modules.

Key features:

  • Lightweight module system with a single TransportClients object (HTTP, gRPC, MQTT).
  • Simple key-value backends (in-memory, Redis, Consul) with a unified interface.
  • FastAPI-based HTTP transport and optional gRPC/MQTT clients.
  • CI workflow with PyPI publishing support via GitHub Actions and OIDC.

Table of Contents

  • Overview
  • Getting Started
  • Configuration
  • Running Locally
  • Testing
  • CI & Publishing
  • Contributing

Overview

DSkity provides a minimal foundation to register independent modules that receive a single TransportClients object containing references to available transport clients (HTTP app, gRPC client, MQTT client). The design keeps optional dependencies lazy-loaded and avoids hard runtime requirements for gRPC or MQTT unless they are used.

Getting Started

Prerequisites:

  • Python 3.11+ (project tests are configured for modern Python versions)
  • Optional: Redis or Consul if you plan to use those KV backends

Install project dependencies (development):

pip install dskity

Configuration

Configuration is handled via the DSkitySettings pydantic settings model in src/dskity/config. You can provide a YAML or environment variables to configure transports and KV backends.

modules:
  service1:
    enabled: true
    database:
      url: "sqlite:///:memory:"
      pool_size: 10
      max_overflow: 20
      pool_pre_ping: true
  service2:
    enabled: false
  service3:
    enabled: true
    database:
      url: "postgresql+psycopg2://user:pass@127.0.0.1:5432/service3"

You can also use envioriments variables to set values:

DSKITY_MODULES_SERVICE3_DATABASE_URL="postgresql+psycopg2://user:superpass@127.0.0.1:5432/service3"

By default, those are the default settings.

"advertise_url": "http://0.0.0.0:8000"
"port": "8000"
"common": 
    "advertise_url": "http://127.0.0.1:8000"
    "internal_base_url": "http://127.0.0.1:8000"
    "registry": 
        "enabled": true
        "heartbeat_interval_seconds": 30
        "ttl_seconds": 60
"config": "./settings.yaml"
"host": "0.0.0.0"
"kv":
    "consul":
        "key_prefix": "dskity"
        "url": "http://127.0.0.1:8500"
        "verify": true
    "default_ttl_seconds": 60
    "redis":
        "key_prefix": "dskity"
        "url": "redis://127.0.0.1:6379/0"
    "ring":
        "vnodes": 64
    "store": "inmemory"
"modules":
"modules_search_paths":
    -"modules"

Running Locally

Run the FastAPI app (when present) or import dskity.bootstrap to construct an application instance.

Example:

dskity

Testing

Run the test suite with pytest:

uv run pytest -q

Tip: this workspace provides uv helper that installs and runs tests with the correct environment; prefer uv run pytest locally.

Module API

Modules must implement a register(self, clients: TransportClients, config: DSkitySettings | dict) -> None method. Use clients.http to access the FastAPI app (if available), clients.grpc for the gRPC client, and clients.mqtt for MQTT.

Optional per-module configuration schema

Modules can optionally expose a small hook that returns a pydantic.BaseModel class describing module-specific additional settings. If present, DSkity will hydrate the module's additional_settings field (available under config.modules.<name>.additional_settings) into an instance of that model before calling register().

Example module hook (minimal):

from pydantic import BaseModel

class HealthAdditionalSettings(BaseModel):
  enabled_checks: list[str] = ["live", "ready"]

class HealthModule:
  meta = ModuleMeta(name="health", base_path="/health")

  def additional_settings_model(self):
    # Return the BaseModel type used to validate/hydrate additional_settings
    return HealthAdditionalSettings

  def register(self, clients, config):
    # config.modules.health.additional_settings is an instance of HealthAdditionalSettings
    pass

This makes it simple for modules to get typed configuration specific to themselves while keeping backwards compatibility for modules that do not declare a schema.

Contributing

Contributions are welcome. Typical workflow:

git checkout -b feature/my-change
pytest
git push --set-upstream origin feature/my-change

Open a pull request for review. Please follow existing code style and update tests when adding or changing behavior.

License

See pyproject.toml / PKG-INFO for license information.

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

dskity-1.0.5.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

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

dskity-1.0.5-py3-none-any.whl (55.2 kB view details)

Uploaded Python 3

File details

Details for the file dskity-1.0.5.tar.gz.

File metadata

  • Download URL: dskity-1.0.5.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dskity-1.0.5.tar.gz
Algorithm Hash digest
SHA256 8508389e166f50e4a0723b1a36f99514a016bd03a30195486345b5b0a6b6da1a
MD5 9cf6715fe86890f5f03957bf04e8e132
BLAKE2b-256 5544bc003827d906c78dc21771968f40c7a9ac0b619ecfe93e54f3b04a0362fb

See more details on using hashes here.

File details

Details for the file dskity-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: dskity-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 55.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dskity-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 65de8651ad1ca7668bf92fb9d7599eaa8bf9781d4f4e62315d6e7e4c5c1d188d
MD5 6276214bd71b65183003f875ebb67610
BLAKE2b-256 14dcc9dc83f1939277754789a001ba9664352dec44920f999cc0fb9f91b869e5

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