Feature flag server SDK for python
Project description
Harness Feature Flag Python SDK
Table of Contents
Intro
Requirements
Quickstart
Further Reading
Build Instructions
Intro
Harness Feature Flags (FF) is a feature management solution that enables users to change the software’s functionality, without deploying new code. FF uses feature flags to hide code or behaviours without having to ship new versions of the software. A feature flag is like a powerful if statement.
- For more information, see https://harness.io/products/feature-flags/
- To read more, see https://ngdocs.harness.io/category/vjolt35atg-feature-flags
- To sign up, https://app.harness.io/auth/#/signup/
Requirements
Python 3.7 or newer (python --version)
pip
For Mac users if you don't already have pyenv or something similar installed for managing python version
Quickstart
The Feature Flag SDK provides a client that connects to the feature flag service, and fetches the value
of featue flags. The following section provides an example of how to install the SDK and initalize it from
an application.
This quickstart assumes you have followed the instructions to setup a Feature Flag project and have created a flag called harnessappdemodarkmode
and created a server API Key.
Install the SDK
Install the python SDK using pip
python -m pip install harness-featureflags
A Simple Example
Here is a complete example that will connect to the feature flag service and report the flag value every 10 seconds until the connection is closed.
Any time a flag is toggled from the feature flag service you will receive the updated value.
import time
from featureflags.client import CfClient
from featureflags.config import *
from featureflags.evaluations.auth_target import Target
from featureflags.util import log
def main():
# API Key
apiKey = "c9b3f14f-6336-4d23-83b4-73f29d1ebeeb"
# Create a Feature Flag Client
client = CfClient(apiKey)
# Create a target (different targets can get different results based on rules)
target = Target(identifier='mytarget', name="FriendlyName")
# Loop forever reporting the state of the flag
while True:
result = client.bool_variation('harnessappdemodarkmode', target, False)
log.info("Flag variation %s", result)
time.sleep(10)
close()
if __name__ == "__main__":
main()
Running the example
$ python3 examples/basic_example/basic.py
Additional Reading
Further examples and config options are in the further reading section:
Harness is a feature management platform that helps teams to build better software and to test features quicker.
======= History
1.0.1 (2021-07-07)
- First release on PyPI.
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
Built Distribution
Hashes for harness-featureflags-1.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 369449c15a81478bbf34b23a33f92c11fc9ca17cd6b2defa511e47cb12ba5224 |
|
MD5 | 2c2d047ce751d6de507a31dd53c13c18 |
|
BLAKE2b-256 | b7750bb96043844327fda6d0bf2d8ce5cd4071989e2f2be7c4390c1bf5cdc8e3 |
Hashes for harness_featureflags-1.0.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b79a26de6295d2ede1fc0a779f119d74540c1fc10caaab686f6cff5c58882583 |
|
MD5 | d09d323913dd8ef3bac921a97fe2dad9 |
|
BLAKE2b-256 | 4bf3ef5cb547cebfc0765e5e9b985304119daa8ee5bb0fe33eb12fb0ffa5829d |