asynchronous configuration provider ( tailored to support dynamic client-server relations)
Project description
fakts
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. These grants are at the moment highly specific to the arkitekt platform and subject to change.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fakts-1.0.0.tar.gz
.
File metadata
- Download URL: fakts-1.0.0.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-44-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65da873b1b3d93f2993c45a5da8b2a7d7176241525aae4acb7cbe9d042342e48 |
|
MD5 | d32d90c1d08921826eff9d0f1ff9d67b |
|
BLAKE2b-256 | d479e6ba7230626852bd1a51158576d24abc77bc01b893e2be7e6869a4782320 |
File details
Details for the file fakts-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: fakts-1.0.0-py3-none-any.whl
- Upload date:
- Size: 53.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-44-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c11f082e3ffc148fa73f072d3b0bd87b3532fd0fc7a6e1ca27d23e5e510898d |
|
MD5 | cea3261de47dbcb59a07278f74cc2c4e |
|
BLAKE2b-256 | e69af1204cc84a9af8f016095d1ecbff021aa249c955aa135f198b7975d8a123 |