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.
Metadata
Release files for heksher 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| heksher-0.2.2.tar.gz | 18.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| heksher-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.7 kB
Release files / heksher-0.2.2.tar.gz
| Download URL | heksher-0.2.2.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8adde305ddaa4fc2d820c3e4b1cd05332f5360e74dd96767cc2d16f8af620b81
|
|
BLAKE2b-256 checksum How to use checksums |
88febb40f2aa86d708f7186eb50ed2e01a419f9cd6ee4e879ac8b18e3e1d88a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.8.16 Linux/5.15.0-1037-azure
|
Release files / heksher-0.2.2-py3-none-any.whl
| Download URL | heksher-0.2.2-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cb2acb971472efdc3918ee19a1aea966aef52f651a8f7182b0655d062b667e5
|
|
BLAKE2b-256 checksum How to use checksums |
1a2e99026b066660e61104437139848bea23c61346545d259363a4b4bb779121
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.8.16 Linux/5.15.0-1037-azure
|