Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Metropolis (Python Microservice Gateway with NATS)

Can we make simple, scalable, observable, operable service gateway?

Purpose

Cloud Native

Single Workload Unit

Service Discovery

Service Mesh

Architecture Concept

  +- Cluster --------------------------------------------------+
  |                                                            |
  |  +- Node-1 --+  +- Node-2 -+  +- Node-3 --+  +- Node-4 -+  |
  |  |           |  |          |  |           |  |          |  |
  |  | Worker-a  |  |          |  |           |  | Worker-d |  |
  |  | Worker-b  |  | Worker-c |  | Worker-a  |  | Worker-c |  |
  |  |    |      |  |    |     |  |    |      |  |    |     |  |
<======= NATS ========= NATS ======================= NATS =======>
  |  |    |      |  |          |  |    |      |  |          |  |
  |  |  Gateway  |  |          |  |  Gateway  |  |          |  |
  |  |    |      |  |          |  |    |      |  |          |  |
  |  +--- | -----+  +----------+  +--- | -----+  +----------+  |
  |       |                            |                       |
  |       +--------------+-------------+                       |
  |                      |                                     |
  |                   Ingress                                  |
  +--------------------- | ------------------------------------+
                         V

Components

Nats

Message bus

Worker

Business Logic worker

Gateway

Service gateway

Example

Install metropolis

$ pip install metropolis

Define Worker task

from metropolis import Worker


worker = Worker(nats='nats://localhost:4222')


@worker.task(subject='foo.bar', queue='worker')
def mytask(data, *args, **kwargs):
    """Simple task which returns reverse string
    """

    return data[0][::-1]


worker.run()

Define Gateway

from metropolis import Gateway
import settings


gateway = Gateway(nats='nats://nats:4222')
gateway.app.run(host='0.0.0.0')

Metadata

Release files for metropolis 0.1.4.dev4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metropolis 0.1.4.dev4
File Size Uploaded
metropolis-0.1.4.dev4.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metropolis 0.1.4.dev4
File Interpreter ABI Platform
metropolis-0.1.4.dev4-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / metropolis-0.1.4.dev4.tar.gz

Download URL metropolis-0.1.4.dev4.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f4dcff07cabda8424967c1c1d8fc9533828f7c61c301defaab63d69e2435aac2
BLAKE2b-256 checksum
How to use checksums
c8667673fdccd4f9238d9dcb757e1720de09c03ac6d8b1ef5ba8b07d62836f36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0

Release files / metropolis-0.1.4.dev4-py3-none-any.whl

Download URL metropolis-0.1.4.dev4-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a79f05905f7ec165ca168c3d9c23615dde9ef0ce648c46f520a3292ddf3c4081
BLAKE2b-256 checksum
How to use checksums
0e674284813602a710275372ca369e5fe8738176ffd69622190d94856817fd34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page