Skip to main content

Framework for services around DSW

Project description

Engine Gateway

Engine Gateway is a lightweight orchestration layer that makes it easy to mount, compose, and run multiple FastAPI applications as a distributed service for easier deployment. It dynamically loads app modules based on configuration and exposes them under configurable subpaths — enabling modular service composition, clean boundaries between components, and centralized deployment.

Usage

Installation

pip install dsw-engine-gateway
# or specific version
pip install dsw-engine-gateway==0.1.0
# or from repository
pip install git+https://github.com/ds-wizard/engine-gateway.git#egg=engine-gateway

Configuration

Create a configuration file (e.g., config.yaml) to define the applications to be mounted:

mounts:
  /example1:
    module: example_app
    app: app
  /example2:
    module: another_app.app
    factory: create_app
    kwargs:
      debug: true

Naturally, the module should be importable in your Python environment (i.e. having installed Python package exporting that module). You can specify either an app variable (a FastAPI instance) or a factory function that returns a FastAPI instance. Additional keyword arguments can be passed to the factory function via kwargs.

If hosting on different subpath than root, you can configure the base path of the gateway:

gateway:
  root_path: /gateway

You can also configure /info endpoint that reports metadata about the mounted applications:

gateway:
  info:
    enabled: true
    token: secretToken

(See config.example.yaml for more details.)

You can also use the following environment variables to override configuration options:

  • CONFIG_FILE: Path to the configuration file (default: config.yaml).
  • GATEWAY_ROOT_PATH: Base path for the gateway (overrides gateway.root_path).
  • GATEWAY_INFO_ENABLED: Enable or disable the /info endpoint (overrides gateway.info.enabled).
  • GATEWAY_INFO_TOKEN: Token for accessing the /info endpoint (overrides gateway.info.token).
  • SENTRY_DSN: DSN for Sentry error tracking (enables Sentry integration if set).
  • SENTRY_TRACES_SAMPLE_RATE: Sample rate for Sentry performance tracing (default: 1.0).
  • SENTRY_PROFILES_SAMPLE_RATE: Sample rate for Sentry profiling (default: 1.0).
  • SENTRY_MAX_BREADCRUMBS: Maximum number of breadcrumbs to store in Sentry (default: 100).
  • SENTRY_ENVIRONMENT: Environment name for Sentry (default: production).
  • SENTRY_AWS_LAMBDA: Enable AWS Lambda integration for Sentry (default: false).

Usage

You can run the Engine Gateway using Uvicorn:

uvicorn engine_gateway:create_app --host

In typical use cases, you would use engine_gateway as a dependency and re-packing it together with your config files and environment setup into a Docker image for deployment:

FROM dsw-engine-gateway:latest

COPY requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

COPY config.yaml /app/config.yaml

CMD ["uvicorn", "engine_gateway:create_app", "--host", "0.0.0.0", "--port", "80", "--proxy-headers"]

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

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

dsw_engine_gateway-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

dsw_engine_gateway-0.1.0-py2.py3-none-any.whl (11.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: dsw_engine_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dsw_engine_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a45e26521f5d3fff7471a15b240019ef028bd4b6a2a47fae448afd369c18c27
MD5 ac8b2ebc8447dc6ca699dacfb4436cf1
BLAKE2b-256 2f19375586cbe7036cfb360666bd3a41611c7a034a612d84648e00c27e95b6f5

See more details on using hashes here.

File details

Details for the file dsw_engine_gateway-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dsw_engine_gateway-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc9d3d0cd86cee45386b87322d0839ab528374dd634adbcb936c33dd313b5f14
MD5 0179901c896c284f4f3fcdfae6f413b1
BLAKE2b-256 7418d92d73a75b91ade45c8b424251f69f988efae64063f392ac18d93113af55

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