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?

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

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.dev3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

metropolis-0.1.4.dev3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: metropolis-0.1.4.dev3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for metropolis-0.1.4.dev3.tar.gz
Algorithm Hash digest
SHA256 f54ff36826158dc833bb4020bf29ee3999b17b903ccf6296d2a3391b438aca38
MD5 7fd1d487b5adde27c277fe5453644af1
BLAKE2b-256 7352747fee55db740e16c870285b7196d9abf2f6818aca47c5f0ec2ff24bc784

See more details on using hashes here.

File details

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

File metadata

  • Download URL: metropolis-0.1.4.dev3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for metropolis-0.1.4.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 5bb33832ddc50a00819986a8c4ab63a64d8f4fb18a0fc286f17de644dfd04051
MD5 bdd7c7310f13d4919bb81bb1f1db935d
BLAKE2b-256 af006881830a61ed3397977babddb97a4580fdc44a2bda678af27e9d3942881f

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