No project description provided
Project description
heksher SDK for python
This is a library for using a heksher server from within python. Compatible with python 3.7, 3.8, and 3.9. The library contains both an asynchronous client, as well as a thread-based client. Also included are stub clients to make testing without a service simple.
Example usage
# main.py
from contextvars import ContextVar
from heksher import AsyncHeksherClient, Setting
user = ContextVar('user', default='guest')
class App:
...
async def startup(self):
...
# initialize the client, and set it as the process' main client
self.heksher_client = AsyncHeksherClient('http://heksher.service.url',
update_interval=60,
context_features=['user', 'trust', 'theme'])
# set certain context features to be retrieved either from string constants or
# context variables
self.heksher_client.set_defaults(user = user, theme="light")
await self.heksher_client.set_as_main()
async def shutdown(self):
await self.heksher_client.close()
...
cache_size_setting = Setting('cache_size', type=int, configurable_features=['user', 'trust'], default_value=10)
def foo(trust: str):
...
# should be run after App.startup is completed
cache_size = cache_size_setting.get(trust=trust)
...
Thread-based client usage is nearly identical.
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
heksher-0.1.0.tar.gz
(14.4 kB
view details)
Built Distribution
heksher-0.1.0-py3-none-any.whl
(19.7 kB
view details)
File details
Details for the file heksher-0.1.0.tar.gz
.
File metadata
- Download URL: heksher-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf6cd03d73b26618b2598112890fc26948655c9a637eb7f543d5317c841c4656 |
|
MD5 | 3f32890186f4477f77881e77b1804df4 |
|
BLAKE2b-256 | 69ac48bc46bab6e58d42a7cc7523f33c67e02efd9225b610682e765026dbbe6e |
File details
Details for the file heksher-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: heksher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a106fd009d96f5b900c618da1f59dd3d64f609effbc37ebf011bf3d8b71a5b8 |
|
MD5 | 8dbdf334412701c6c1c74317ca4b12c6 |
|
BLAKE2b-256 | a522a98db33b07f37fc9fca4d353acddb1c37f9c8ff3e88b7d4d8fd940c225c6 |