Skip to main content

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


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.5.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

heksher-0.1.5-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file heksher-0.1.5.tar.gz.

File metadata

  • Download URL: heksher-0.1.5.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for heksher-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8109c52ea41d68cecfc26283736c53fe0a963c39fe79d391bb8a03cee7e5137d
MD5 15897be32d49bb05cea35e6c03358532
BLAKE2b-256 08837782c2f5629b9f17d0ab80eccd9397edf4f45adfaad3f088f3ea0f8423eb

See more details on using hashes here.

File details

Details for the file heksher-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: heksher-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for heksher-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 635f36029f0df12c507631abd8b69ceac0c99085acf6d5f276e8bc9a795ad820
MD5 bc04c0f5ae23ce2141cc22da155bde71
BLAKE2b-256 3fdd48cbfd98311a4bbf34e02070bae834bb9f288d1529f1e2ed20443efd38b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page