Skip to main content

asynchronous configuration provider ( tailored to support dynamic client-server relations)

Project description

fakts

codecov PyPI version Maintenance Maintainer PyPI pyversions PyPI status PyPI download day Code style: black Checked with mypy Ruff

Inspiration

Fakts was designed to make configuration of apps compatible with modern concurrency patterns, it is designed to allow for asynchronous retrieval of configuration from various sources, may it be a config file, environmental variables or a remote server (via the "fakts remote protocol", described in the documentation.).

Fakts was conceived as a way to provide a configuration interface for the arkitekt platform, where clients needed to dynamically retrieve configuration from a remote server, but it is designed to be used in any python project.

Core Design

Fakts uses Grants to obtain configuration asynchronously, a grant is a way of retrieving the configuration from a specific source. It can be a local config file (eg. yaml, toml, json), environemnt variables, a remote configuration (eg. from a fakts server), or a database. The Fakts class then wraps the grant to ensure both a sychronous and asychronous interface that is threadsafe.

Grants are designed to be composable through MetaGrants so by desigining a specifc grant structure, one can highly customize the retrieval logic. Please check out the documentation for more information.

Example:

By default fakts follows a key-value structure, where the key is a string, and the value can be any serializable python object.

async with Fakts(grant=YamlGrant("config.yaml")) as fakts:
    config = await fakts.aget("group_name")
    # will return the configuration for the group_name key in the yaml file

or

with Fakts(grant=YamlGrant("config.yaml")) as fakts:
    value = fakts.get("nested.key.path")
    # will return the configuration for a nested key in the yaml file

Fakts should be used as a context manager, and will set the current fakts context variable to itself, letting you access the current fakts instance from anywhere in your code (async or sync) without specifically passing a referece.

Composability

You can compose grants through meta grants in order to load configuration from multiple sources (eg. a local, file that can be overwritten by a remote configuration, or some envionment variables).

Example:

async with Fakts(grant=FailsafeGrant(
    grants=[
        EnvGrant(),
        YamlGrant("config.yaml")
    ]
)) as fakts:
    config = await fakts.get("group_name")

In this example fakts will load the configuration from the environment variables first, and if that fails, it will load it from the yaml file.

Fakts Remote Protocol

Fakts provides the remote grant protocol for retrieval of configuration in dynamic client-server relationships. With these grants you provide a software manifest for a configuration server (fakts-server), that then grants the configuration (either through user approval (similar to device code grant)). These grants are mainly used to setup or claim an oauth2 application on the backend securely that then can be used to identify the application in the future.

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

fakts_next-3.0.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

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

fakts_next-3.0.0-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file fakts_next-3.0.0.tar.gz.

File metadata

  • Download URL: fakts_next-3.0.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fakts_next-3.0.0.tar.gz
Algorithm Hash digest
SHA256 01f63ecea78531749e20d20bd25d3c1ebb10d53048e253c5d7da6766076282a0
MD5 2372fd85043bee7e0882d49cbfd04065
BLAKE2b-256 ef03c043ab27f0821d878cdafb3c02b4af9de08f66fa1165ba5280348c74ddd2

See more details on using hashes here.

File details

Details for the file fakts_next-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: fakts_next-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 51.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fakts_next-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78edb08ca0ea1d88e3bd0e0d87a79ebb53443a4203ce459d07888fcfc0a9e229
MD5 7e25db5672773cc7b2a0d8db506e68d5
BLAKE2b-256 0a22d84b2c53b88129b057e97519922da69af8f4cdcb7205c4fdd7cfb1f7c372

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