Skip to content

Commit ede1afc

Browse files
committed
First import
0 parents  commit ede1afc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+8417
-0
lines changed

.gitignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Created by https://www.gitignore.io
2+
3+
# doc
4+
doc/_build
5+
6+
### Python ###
7+
# Byte-compiled / optimized / DLL files
8+
__pycache__/
9+
*.py[cod]
10+
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
env/
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
57+
# Sphinx documentation
58+
docs/_build/
59+
60+
# PyBuilder
61+
target/
62+
.ropeproject
63+
# Created by https://www.gitignore.io
64+
65+
### vim ###
66+
[._]*.s[a-w][a-z]
67+
[._]s[a-w][a-z]
68+
*.un~
69+
Session.vim
70+
.netrwhist
71+
*~
72+
73+
.build
74+
hosts

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Changlog
2+
=========
3+
4+
# TODO

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) <2019> <Eleme Inc.>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
develop:
2+
pip install -e ".[test,doc]"
3+
.PHONY: develop
4+
5+
tag:
6+
@git tag v`python setup.py --version`
7+
.PHONY: tag
8+
9+
changelog:
10+
@git log --no-merges v`python setup.py --version`.. --pretty="format: * %s"
11+
.PHONY: changelog
12+
13+
clean:
14+
rm -rf build dist *.egg-info
15+
find . -type d -name "__pycache__" | xargs rm -rf
16+
find . -name "*.pyc" -delete
17+
.PHONY: clean
18+
19+
lint:
20+
mkdir -p .build
21+
pylint --rcfile tools/pylint/pylintrc huskar_sdk_v2 | tee .build/pylint.out
22+
.PHONY: lint
23+
24+
test: clean lint
25+
tox
26+
.PHONY: test
27+
28+
hooks:
29+
ln -sf ../../tools/git-hooks/pre-commit .git/hooks/pre-commit
30+
.PHONY: hooks

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Huskar SDK
2+
3+
- [Documentation](https://github.com/huskar-org/huskar-python)
4+
5+
- [Toturial](https://github.com/huskar-org/huskar-python)
6+
7+
- [CHANGELOG](CHANGELOG.md)
8+
9+
10+
## Install
11+
12+
``pip install -e .``
13+
14+
With extra dependencies of doc:
15+
16+
``pip install -e ".[doc]"``
17+
18+
With extra dependencies of tests:
19+
20+
``pip install -e ".[test]"``
21+
22+
Install all
23+
``make develop``
24+
25+
26+
## Tests
27+
28+
run
29+
30+
``python setup.py test``
31+
or
32+
``make test`
33+
34+
## 分支版本
35+
36+
0.x.y:
37+
38+
* x 代表是否有不兼容.
39+
* y 为自动同一兼容性下, 自动升级的版本. 会自动在线上安装.
40+
41+
总共维护 3 个不兼容.
42+
43+
* 最新版本分支: master
44+
* 0.13.x 版本分支: v0.13.x
45+
* 0.14.x 版本分支: v0.14.x
46+
47+
48+
## Kazoo
49+
50+
Kazoo 仅在使用 `BootstrapHuskar` 时用到, 这是供 Huskar API 自举用的接口。
51+
52+
对于其他使用方, 建议只使用 `HttpHuskar` , 这是唯一受支持的 Huskar 接入方式。
53+
54+
我们依赖的 Kazoo 版本是基于上游 2.0 版本 fork 的[一个分支](https://github.com/huskar-org/kazoo/tree/eleme-2.0)
55+
其中 backport 了一些 hotfix 和特性。
56+
57+
至于为什么不升级到最新版本的 Kazoo,历史中留存了一份解释。
58+
59+
> 我们上次 `add_auth` 导致的 xid mismatch 的问题, 结合
60+
> https://github.com/python-zk/kazoo/pull/305, 以及我对比 ZooKeeper Java Client
61+
> 和 Kazoo 实现的结果,可以得出一个结论: Kazoo 的连接管理中 `def _invoke`
62+
> 这种不经过队列直接递交连接时请求的行为是完全有可能导致 race condition 的…
63+
> 目前的 Kazoo 版本结合 huskar-sdk 实现算是很小心地躲开已知的石子,
64+
> 如果换个姿势就未必还能躲开了。
65+
>
66+
> 这个问题如果没有(通过 Kazoo 重构)彻底解决,我建议我们不要再抱有升级 Kazoo
67+
> 的想法了。如果需要上游的某个 patch,我们可以 backport 到我们 fork 的分支。
68+
69+
## FAQ
70+
71+
### 在面板上添加的数据用 SDK 取不到
72+
请确认:
73+
74+
1. Huskar SDK 连接的服务器和面板是否相同
75+
2. Huskar SDK 使用的服务名称和面板的服务名称是否相同
76+
3. 功能模块是否有弄错?配置和开关分别对应面板中的 `Config``Switch`
77+
4. Huskar SDK 使用的版本是否 **过旧** ,一般来说我们推荐使用 [已发布的最新版](https://github.com/huskar-org/huskar-python/releases)
78+
79+
80+
## 特性
81+
82+
* 开关修改实时生效
83+
* 以/team/project/project_module/cluster/api为粒度进行管理,例如:/arch/test/test_233/test_6666/query_by_geohash
84+
* 以user和team为单位进行权限分配,以api为粒度进行权限设置(change/delete/read)。
85+
* 以比例形式设置接口开关,例如:设置开关大小为50%,则所有流量的50%经过接口处理,50%的流量返回默认。
86+
* 默认返回的方式: 以decorator的方式设置接口返回的默认值.

0 commit comments

Comments
 (0)