Skip to main content

Microservice gateway using Nats

Project description

Metropolis (Python Microservice Gateway with NATS)

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

Architecture Concept

+- 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

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')

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

metropolis-0.1.4.dev1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

metropolis-0.1.4.dev1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file metropolis-0.1.4.dev1.tar.gz.

File metadata

  • Download URL: metropolis-0.1.4.dev1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

File hashes

Hashes for metropolis-0.1.4.dev1.tar.gz
Algorithm Hash digest
SHA256 28acb0b9c2f1662b441a606e14ce4678e76ec188b932b8771861a5d0af0799cf
MD5 8c4e642556b0ae7fc5a886167a9341c9
BLAKE2b-256 8db45ab83acb957189ccbf054cbe90aa8431f062c5617449b3014d7438e3adc3

See more details on using hashes here.

File details

Details for the file metropolis-0.1.4.dev1-py3-none-any.whl.

File metadata

  • Download URL: metropolis-0.1.4.dev1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

File hashes

Hashes for metropolis-0.1.4.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1daecdfc342d5219e04620d8a27aa8f5f55061337fadab17b063f3ae2d9f889
MD5 c6a949ac65d0391b1984011882de2ee7
BLAKE2b-256 54bf8ef5880e21f720a4e3d5a9ed897a8118a8b2316cce7f8e11b96ab5ea4e6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page