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

Uploaded Source

Built Distribution

heksher-0.1.3-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: heksher-0.1.3.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

Hashes for heksher-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7844ecc29fe81b78ffd3550382df1a8bfe3de86efa5ccc982d02637e2fc3031c
MD5 6931f3e0e4035ed3f310752da952d92a
BLAKE2b-256 f77bdaa5f0d5e42dd225624a0b40f2e743ae3c97147671de698f857c9fc5390c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: heksher-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 20.5 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

Hashes for heksher-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e899f224aada59ec1ea56c460194aec98cbcd9d59dd1b665d00e7784e00d8a5e
MD5 a45ecb1f492484a1a2170ec75434b40c
BLAKE2b-256 988b0e987971b0ee635c09fa0431948ee98c38060a05822f3e684fdbdfe4c1f2

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