Skip to main content

No project description provided

Project description

FastMicroservices

Connect FastAPI microservices easily.

Install

pip install fastmicroservices

Usage

import time

from toomanythreads import ThreadedServer

from fastmicroservices import Macroservice
from fastmicroservices import Microservice


class Dummy(ThreadedServer, Microservice):
    def __init__(self, macroservice: Macroservice):
        ThreadedServer.__init__(self)
        Microservice.__init__(self, macroservice)

        @self.get("/")
        def foobar():
            return "foobar"


if __name__ == "__main__":
    m = Macroservice()
    serv = Dummy(m)
    m.thread.start()
    time.sleep(100)

How it works

The core routing engine uses /page/{page_name}/{path:path}:

  • Automatic Directory Construction: The backend uses TooManyConfigs and FastJ2 to automatically provision a templates folder and render from it.
  • Service Discovery: Macroservice finds your service by page_name, which is the lowercase class' name. In the above instance, it would be http://localhost:{port}/page/dummy
  • Internal Routing: Your service handles its own routes via the forward() method. You can code your own forwarding method, but ThreadedServer already provides this. See https://pypi.org/project/toomanythreads/

Example: /page/dummy/api/users → finds "dummy" service → calls dummy.forward("/api/users") Static HTML files in templates/static_pages/ work the same way but just render templates.

Licensed under MIT.

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

fastmicroservices-0.1.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

fastmicroservices-0.1.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file fastmicroservices-0.1.4.tar.gz.

File metadata

  • Download URL: fastmicroservices-0.1.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.2 Windows/11

File hashes

Hashes for fastmicroservices-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b2c9d6c8dbe71356f7096ac7461462c7e6d1a9fba449b2732aa91504078d17c2
MD5 b7fc6e7236fb16afb13d06443d49ef3b
BLAKE2b-256 baa865ba3c946d007fa579d90b6d11c95abc2e2f6d7fa9f7e452e3af2bc5490a

See more details on using hashes here.

File details

Details for the file fastmicroservices-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: fastmicroservices-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.2 Windows/11

File hashes

Hashes for fastmicroservices-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5617fae3e3e4598a125eb7488ce8148e93dbf4fc73c7eb7b8d20f35fdcaa1027
MD5 d0e802769f4412befc2b85d191e27c1e
BLAKE2b-256 dfc3395c3e954b749a97b2c774a14fd88a470c4e51b7d51e845cc84e9ad2596a

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