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.4.tar.gz
(14.9 kB
view details)
Built Distribution
heksher-0.1.4-py3-none-any.whl
(20.4 kB
view details)
File details
Details for the file heksher-0.1.4.tar.gz
.
File metadata
- Download URL: heksher-0.1.4.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56faeb3e7bde39b56442268aad23b4af0bc32a933f9767c9ab4b5ad677eac4ba |
|
MD5 | 6f4252fcf6f2c5e0eb4ed9109f45d2f7 |
|
BLAKE2b-256 | f173313c9be570088534887d9d06976d9e96682995b4ee0b75c5bdf517534da5 |
File details
Details for the file heksher-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: heksher-0.1.4-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a51ce100eb8656b6d6e1bcdc29f6aa4efab86f169ffd210cf361d35b47787265 |
|
MD5 | a4db436c57d40120dedf21ebd62edd1e |
|
BLAKE2b-256 | ce03e7be39b8768264f3e2a8d4e034f02bc1b42b8ef99fdebe06ba0b87b9c63d |