用于释放功能切换系统的python客户端!
UnleashClient的Python项目详细描述
释放客户端python
这是Unleash的python客户端。它实现Client Specifications 1.0,并根据unleash/client-specifications中的规范检查遵从性
它支持的功能:
- 使用32位Murmerhash3的默认激活策略
- 自定义策略
- 完整的客户端生命周期:
- 客户端向释放服务器注册
- 客户端定期获取功能切换并存储到磁盘缓存
- 客户端定期发送度量以释放服务器
查看project documentation和changelog。
安装
查看Pypi上的包!
pip install UnleashClient
用法
初始化
from UnleashClient import UnleashClient
client = UnleashClient("https://unleash.herokuapp.com/api", "My Program")
client.initialize_client()
优雅地清理:
client.destroy()
参数
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 | {} |
检查功能是否已启用
检查一个简单的开关:
client.is_enabled("My Toggle")
指定默认值:
client.is_enabled("My Toggle", default_value=True)
提供应用程序上下文:
app_context = {"userId": "test@email.com"}
client.is_enabled("User ID Toggle", app_context)