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

Uploaded Source

Built Distribution

heksher-0.2.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: heksher-0.2.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.13.0-1021-azure

File hashes

Hashes for heksher-0.2.1.tar.gz
Algorithm Hash digest
SHA256 23ebb4f0f73333a954a6395e6987c19dee72ab1757928a49e8e466ca25e91602
MD5 0c05f3cc03a0c465cf6cd622bb625167
BLAKE2b-256 bc1a5b98da1c639483b39ff24cfdae46fa6bba88d0142e906faaf842d5c4aeb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: heksher-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.13.0-1021-azure

File hashes

Hashes for heksher-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e90d09490499156381f29199edc4fd8090a11fd09a5a0fdd119cfa7ad6ef41b8
MD5 313930279943658d54d8793e2836dbf1
BLAKE2b-256 5fe1d44187f611521fc5395d3121f9bf49c05115b195d5e54c2e5b112fec6b70

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