Skip to content
Unleash client for Python πŸ’‘πŸ’‘πŸ’‘
Python Makefile
Branch: master
Clone or download
ivanklee86 Rc 2.4.0 (#28)
* Update changelog.

* Automatic version bump via bumpversion.
Latest commit 5fec9d3 Jul 31, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
.github Added client spec tests (& fixed a bunch of bugs) Oct 13, 2018
UnleashClient Rc 2.4.0 (#28) Jul 30, 2019
docs Rc 2.4.0 (#28) Jul 30, 2019
tests feat: add support static context fields (#24) Jul 30, 2019
.bumpversion.cfg Rc 2.4.0 (#28) Jul 30, 2019
.flake8 Improve caching. (#27) Oct 12, 2018
.gitignore Minor tweaks and documentation. Oct 12, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Oct 12, 2018
CONTRIBUTING.md Update CONTRIBUTING.md Oct 12, 2018
LICENSE.md Initial setup, pt 1. Oct 3, 2018
MANIFEST.in Add manifest file. (#25) Jul 2, 2019
Makefile Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
Pipfile Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
Pipfile.lock Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
README.md feat: add support static context fields (#24) Jul 30, 2019
mkdocs.yml Custom strategies Oct 13, 2018
mypy.ini Implementing Unleash default strategies Oct 9, 2018
pylintrc feat: add support static context fields (#24) Jul 30, 2019
pytest.ini Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
requirements-dev.txt Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
requirements-local.txt Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
requirements-package.txt Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
requirements.txt Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
setup.config Initial commit. Oct 2, 2018
setup.py Rc 2.4.0 (#28) Jul 30, 2019
tox-osx.ini Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019
tox.ini Remove pipenv, support Python 3.5, 3.6, 3.7, 3.8 in CI Apr 13, 2019

README.md

unleash-client-python

CircleCI Coverage Status PyPI version PyPI - Python Version License: MIT

This is the Python client for Unleash. It implements Client Specifications 1.0 and checks compliance based on spec in unleash/client-specifications

What it supports:

  • Default activation strategies using 32-bit Murmerhash3
  • Custom strategies
  • Full client lifecycle:
    • Client registers with Unleash server
    • Client periodically fetches feature toggles and stores to on-disk cache
    • Client periodically sends metrics to Unleash Server

Check out the project documentation and the changelog.

Installation

Check out the package on Pypi!

pip install UnleashClient

Usage

Initialization

from UnleashClient import UnleashClient
client = UnleashClient("https://unleash.herokuapp.com/api", "My Program")
client.initialize_client()

To clean up gracefully:

client.destroy()

Arguments

Argument Description Required? Type Default Value
url Unleash server URL Y String N/A
app_name Name of your program Y String N/A
environment Name of current environment N String default
instance_id Unique ID for your program N String unleash-client-python
refresh_interval How often the unleash client should check for configuration changes. N Integer 15
metrics_interval How often the unleash client should send metrics to server. N Integer 60
disable_metrics Disables sending metrics to Unleash server. N Boolean F
disable_registration Disables registration with Unleash server. N Boolean F
custom_headers Custom headers to send to Unleash. N Dictionary {}
custom_strategies Custom strategies you'd like UnleashClient to support. N Dictionary {}

Checking if a feature is enabled

A check of a simple toggle:

client.is_enabled("My Toggle")

Specifying a default value:

client.is_enabled("My Toggle", default_value=True)

Supplying application context:

app_context = {"userId": "test@email.com"}
client.is_enabled("User ID Toggle", app_context)
You can’t perform that action at this time.