Skip to main content

A pluggable server

Project description

FPS

FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins. It is based on top of fastAPI, uvicorn, typer, and pluggy.

How it works

The main purpose of FPS is to provide hooks to register endpoints, static mounts, CLI setups/teardowns, etc.

An application can then be composed by multiple plugins providing specific/specialized endpoints. Those can be registered using fps.hooks.register_router with a fastapi.APIRouter.

What is coming soon

The most important parts will be to have a nice configuration system and also a logger working through multiprocesses, with homogeneous formatters to give devs/ops/users a smooth experience.

Concepts

Few concepts are extensively used in FPS:

  • a hook, or hook implementation, is a method tagged as implementing a hook specification
    • a hook specification is the declaration of the hook
      @pluggy.HookspecMarker(HookType.ROUTER.value)
      def router() -> APIRouter:
          pass
      
    • hooks are automatically collected by FPS using Python's entry_points, and ran at the right time
      [options.entry_points]
      fps_router =
          fps_helloworld_router = fps_helloworld.routes
      fps_config =
          fps_helloworld_config = fps_helloworld.config
      
    • multiple entry_points groups are defined (e.g. fps_router, fps_config, etc.)
      • a hook MUST be declared in its corresponding group to be collected
      • in the previous example, HookType.ROUTER.value equals fps_router, so the router hook is declared in that group
    • fps.hooks.register_<hook-name> helpers are returning such hooks
      def register_router(r: APIRouter):
          def router_callback() -> APIRouter:
              return r
      
          return pluggy.HookimplMarker(HookType.ROUTER.value)(
              function=router_callback, specname="router"
          )
      
  • a plugin is a Python module declared in a FPS's entry_point
    • a plugin may contain zero or more hooks
    • in the following helloworld example, the hook config is declared but not the plugin_name one. Both are hooks of the fps_config group.
      from fps.config import PluginModel
      from fps.hooks import register_config
      
      
      class HelloConfig(PluginModel):
          random: bool = True
      
      
      c = register_config(HelloConfig)
      
  • a plugins package is a Python package declaring one or more plugins

Configuration

FPS now support configuration using toml format.

Precedence order

For now, the loading sequence of the configuration is: fps.toml < <plugin-name>.toml < <cli-passed-file> < <cli-arg>.

fps.toml and <cli-passed-file> files can contain configuration of any plugin, while <plugin-name>.toml file will only be used for that specific plugin.

fps.toml and <plugin-name>.toml currently have to be in the current working directory. Support for loading from user home directory or system-wide application directory will be soon implemented.

Note: the environment variable FPS_CONFIG_FILE is used to store cli-passed filename and make it available to subprocesses.

Merging strategy

At this time the merging strategy between multiple config sources is pretty simple:

  • dict values for higher precedence source win
  • no appending/prepending on sequences

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

fps-0.0.6.post1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

fps-0.0.6.post1-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fps-0.0.6.post1.tar.gz.

File metadata

  • Download URL: fps-0.0.6.post1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for fps-0.0.6.post1.tar.gz
Algorithm Hash digest
SHA256 9b04a15aabc49a6711bbcf946d8befd3662edaffcf676ea7994c39fbc185294e
MD5 4d3da1fba925f4c2e48dc02284c10583
BLAKE2b-256 fd3ba700a301dbf84a01e1289b0b7047d72fd5984d9b5bbc8f75cc60cabc2afe

See more details on using hashes here.

File details

Details for the file fps-0.0.6.post1-py2.py3-none-any.whl.

File metadata

  • Download URL: fps-0.0.6.post1-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for fps-0.0.6.post1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f3fb013120a6af76feb5364aa3d26a35729b7cf351ad23779352bf7b24e1c3ab
MD5 e2ccc3bc89042c05d747cec6678fcb3f
BLAKE2b-256 fed9acf227099085afb769e0722634905e61e1d23180c543c183c76634f8662d

See more details on using hashes here.

Supported by

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