A Python SDK for feature-flags.co project
Project description
敏捷开关 Python SDK
本项目为 敏捷开关 https://www.feature-flags.co 的 Python SDK
This is a Python SDK for https://www.feature-flags.co, a feature flag management system
安装
pip install feature-flags-co
or
python3 -m pip install feature-flags-co
简易教程
以下为一个简单例子,对于 Web API, 一个 User Session 只需要初始化一次 The following is a simple example, for Web API, only need to initialize once for a single User Session
from feature_flags_co import FfcClient, FfcUser
ffc_user = FfcUser(
user_name='user_name', # 必填
email='email', # 可空
key='key', # userId, 必填
customize_properties= [ # 可以为空 (Can be omitted)
{'name':'phoneNumber', 'value':'13895462538'},
{'name':'tenantId', 'value':'123'}
]
)
# 初始化 Client, 针对一个终端用户只需要初始化一次
# Initialization of the client
ffc_client = FfcClient('environment_secret', ffc_user)
# 调用 variation 方法, 获取具体某一个 feature flag 的值,defaultResult 为当服务器返回异常时默认的返回值
# Call variation method to get the value of a specific feature flag, defaultResult would be result if any exception happened during the call
result = ffc_client.variation('feature-flag-key', default_result='False')
# 接下来根据 result 打开或者关闭某功能
# Now we can use the value of result to switch on/off some fonctionalities
if result:
pass
# 获取当前所有 feature flag 及其值
# results 为 list, 其中的元素为如下的 dict
# {'key_name': '', 'variation': ''}
results = ffc_client.variations()
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file feature-flags-co-0.0.21.tar.gz.
File metadata
- Download URL: feature-flags-co-0.0.21.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1a7cfedfdad61c0eda60530f71225da51f27163038f5e702d88178043f8d08d
|
|
| MD5 |
1018888428dfc3a209321809a9dae66a
|
|
| BLAKE2b-256 |
04f63a890037c8bdc389538c378f298876546fdaca6f7d26fb5b01ec92179baf
|
File details
Details for the file feature_flags_co-0.0.21-py3-none-any.whl.
File metadata
- Download URL: feature_flags_co-0.0.21-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1514c0d807a8182446d03d8dadd18af90e9010714863c58aaaa439c18b84e2d0
|
|
| MD5 |
df271b318a3d6f0a677a0e20d8f8994b
|
|
| BLAKE2b-256 |
3def91219fb7808cddc6e0de77cc1fdbcc577130a876d3e244c0a1c905a8a7d6
|