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.1.tar.gz
(14.4 kB
view details)
Built Distribution
heksher-0.1.1-py3-none-any.whl
(19.7 kB
view details)
File details
Details for the file heksher-0.1.1.tar.gz
.
File metadata
- Download URL: heksher-0.1.1.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 | 9d6e94d96168d72bbcef9d0302a5d07d2d9129350ce1aa9d669a22998f961786 |
|
MD5 | bbe355767a494700fc02b9dbe99f539e |
|
BLAKE2b-256 | 5cb617eb4895c5809c2b1b678f769c832ec07d2d1f96d837220aa4864c5325f7 |
File details
Details for the file heksher-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: heksher-0.1.1-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 | 486c86d4b1adc4fbf7892503822dc0902f735593f5aefd2c35e29c0d6dc86cca |
|
MD5 | 3c30a92c7e59ae95860963baa842085d |
|
BLAKE2b-256 | 62c93cfefb8baeff3feab2f975afca370e0264e7c6a997aff970885ec895dc35 |