You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by wu...@apache.org on 2021/04/14 02:54:55 UTC
[incubator-pegasus-website] branch master updated: add description
of python3-client (#2)
This is an automated email from the ASF dual-hosted git repository.
wutao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus-website.git
The following commit(s) were added to refs/heads/master by this push:
new d5fd771 add description of python3-client (#2)
d5fd771 is described below
commit d5fd77106395df18ad6a3bb7ee344dbbf77f72dc
Author: Smilencer <52...@qq.com>
AuthorDate: Wed Apr 14 10:54:49 2021 +0800
add description of python3-client (#2)
---
_data/docs_menu.yml | 6 +-
_data/en/translate.yml | 3 +-
_data/zh/translate.yml | 3 +-
_docs/zh/clients/clients.md | 3 +-
.../{python-client.md => python2-client.md} | 2 +-
.../{python-client.md => python3-client.md} | 67 +++++++++++-----------
6 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/_data/docs_menu.yml b/_data/docs_menu.yml
index 8e2582f..eff39c1 100644
--- a/_data/docs_menu.yml
+++ b/_data/docs_menu.yml
@@ -16,8 +16,10 @@
link: /clients/cpp-client
- name: title_go-client
link: https://github.com/XiaoMi/pegasus-go-client
- - name: title_python-client
- link: /clients/python-client
+ - name: title_python2-client
+ link: /clients/python2-client
+ - name: title_python3-client
+ link: /clients/python3-client
- name: title_node-client
link: /clients/node-client
- name: title_scala-client
diff --git a/_data/en/translate.yml b/_data/en/translate.yml
index cd5c47d..1394af1 100644
--- a/_data/en/translate.yml
+++ b/_data/en/translate.yml
@@ -26,7 +26,8 @@ title_shell: "Pegasus Shell"
title_java-client: "Java Client"
title_cpp-client: "C++ Client"
title_go-client: "Golang Client"
-title_python-client: "Python Client"
+title_python2-client: "Python2 Client"
+title_python3-client: "Python3 Client"
title_node-client: "NodeJS Client"
title_scala-client: "Scala Client"
title_clients: "Client Libs"
diff --git a/_data/zh/translate.yml b/_data/zh/translate.yml
index 1888218..f009afe 100644
--- a/_data/zh/translate.yml
+++ b/_data/zh/translate.yml
@@ -26,7 +26,8 @@ title_shell: "Pegasus Shell 工具"
title_java-client: "Java客户端"
title_cpp-client: "C++客户端"
title_go-client: "Golang客户端"
-title_python-client: "Python客户端"
+title_python2-client: "Python2客户端"
+title_python3-client: "Python3客户端"
title_node-client: "NodeJS客户端"
title_scala-client: "Scala客户端"
title_clients: "客户端库"
diff --git a/_docs/zh/clients/clients.md b/_docs/zh/clients/clients.md
index f6828b7..7a28194 100644
--- a/_docs/zh/clients/clients.md
+++ b/_docs/zh/clients/clients.md
@@ -8,5 +8,6 @@ Pegasus目前提供以下多种客户端支持:
| Java | <https://github.com/XiaoMi/pegasus-java-client> |
| Scala | <https://github.com/XiaoMi/pegasus-scala-client> |
| Go | <https://github.com/XiaoMi/pegasus-go-client> |
-| Python | <https://github.com/XiaoMi/pegasus-python-client> |
+| Python2 | <https://github.com/XiaoMi/pegasus-python-client> |
+| Python3 | <https://github.com/XiaoMi/pegasus-python-client/tree/python3> |
| NodeJs | <https://github.com/XiaoMi/pegasus-nodejs-client.git> |
diff --git a/_docs/zh/clients/python-client.md b/_docs/zh/clients/python2-client.md
similarity index 99%
copy from _docs/zh/clients/python-client.md
copy to _docs/zh/clients/python2-client.md
index 83d59f0..a594187 100755
--- a/_docs/zh/clients/python-client.md
+++ b/_docs/zh/clients/python2-client.md
@@ -1,5 +1,5 @@
---
-permalink: clients/python-client
+permalink: clients/python2-client
---
# pegasus python client
diff --git a/_docs/zh/clients/python-client.md b/_docs/zh/clients/python3-client.md
similarity index 86%
rename from _docs/zh/clients/python-client.md
rename to _docs/zh/clients/python3-client.md
index 83d59f0..f9a0efa 100755
--- a/_docs/zh/clients/python-client.md
+++ b/_docs/zh/clients/python3-client.md
@@ -1,5 +1,5 @@
---
-permalink: clients/python-client
+permalink: clients/python3-client
---
# pegasus python client
@@ -10,19 +10,21 @@ permalink: clients/python-client
## 版本要求
-Python 2.*
+Python 3.7+
## 安装
-`pip install pypegasus`
+`pip3 install pypegasus3`
## 使用
-pegasus python client使用了[twisted](https://github.com/twisted/twisted), 编写的代码会带有twisted的影子。
+pegasus python3 client 从 python2-client 改动而来,对原有的接口参数做了破坏性改动,由`str`改为`bytes`,并不再支持 python2 环境。
+
+其他使用方法与 python2 客户端无差异
### 示例
-完整的示例请参考[sample](https://github.com/XiaoMi/pegasus-python-client/blob/master/sample.py)。以下是简单的示例:
+完整的示例请参考[sample](https://github.com/XiaoMi/pegasus-python-client/blob/python3/sample.py)。以下是简单的示例:
```
#!/usr/bin/env python
@@ -54,7 +56,7 @@ def basic_test():
# get
ret = yield c.get('hkey1', 'skey1')
- print('get ret: ', ret)
+ print('get ret: ', bytes.decode(ret))
reactor.stop()
@@ -107,7 +109,7 @@ class Pegasus(object):
"""
:param meta_addrs: (list) pagasus meta servers list.
example: ['127.0.0.1:34601', '127.0.0.1:34602', '127.0.0.1:34603']
- :param table_name: (str) table name/app name used in pegasus.
+ :param table_name: (bytes) table name/app name used in pegasus.
:param timeout: (int) default timeout in milliseconds when communicate with meta sever and replica server.
"""
```
@@ -130,8 +132,8 @@ def ttl(self, hash_key, sort_key, timeout=0):
"""
Get ttl(time to live) of the data.
- :param hash_key: (str) which hash key used for this API.
- :param sort_key: (str) which sort key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param sort_key: (bytes) which sort key used for this API.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
@@ -150,8 +152,8 @@ def exist(self, hash_key, sort_key, timeout=0):
"""
Check value exist.
- :param hash_key: (str) which hash key used for this API.
- :param sort_key: (str) which sort key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param sort_key: (bytes) which sort key used for this API.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
@@ -170,9 +172,9 @@ def set(self, hash_key, sort_key, value, ttl=0, timeout=0):
"""
Set value to be stored in <hash_key, sort_key>.
- :param hash_key: (str) which hash key used for this API.
- :param sort_key: (str) which sort key used for this API.
- :param value: (str) value to be stored under <hash_key, sort_key>.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param sort_key: (bytes) which sort key used for this API.
+ :param value: (bytes) value to be stored under <hash_key, sort_key>.
:param ttl: (int) ttl(time to live) in seconds of this data.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
@@ -192,7 +194,7 @@ def multi_set(self, hash_key, sortkey_value_dict, ttl=0, timeout=0):
"""
Set multiple sort_keys-values under hash_key to be stored.
- :param hash_key: (str) which hash key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
:param sortkey_value_dict: (dict) <sort_key, value> pairs in dict.
:param ttl: (int) ttl(time to live) in seconds of these data.
:param timeout: (int) how long will the operation timeout in milliseconds.
@@ -213,12 +215,12 @@ def get(self, hash_key, sort_key, timeout=0):
"""
Get value stored in <hash_key, sort_key>.
- :param hash_key: (str) which hash key used for this API.
- :param sort_key: (str) which sort key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param sort_key: (bytes) which sort key used for this API.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
- :return: (tuple<error_types.code.value, str>) (code, value).
+ :return: (tuple<error_types.code.value, bytes>) (code, value).
code: error_types.ERR_OK.value when data got succeed, error_types.ERR_OBJECT_NOT_FOUND.value when data not found.
value: data stored in this <hash_key, sort_key>
"""
@@ -238,7 +240,7 @@ def multi_get(self, hash_key,
"""
Get multiple values stored in <hash_key, sortkey> pairs.
- :param hash_key: (str) which hash key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
:param sortkey_set: (set) sort keys in set.
:param max_kv_count: (int) max count of k-v pairs to be fetched. max_fetch_count <= 0 means no limit.
:param max_kv_size: (int) max total data size of k-v pairs to be fetched. max_fetch_size <= 0 means no limit.
@@ -266,9 +268,9 @@ def multi_get_opt(self, hash_key,
"""
Get multiple values stored in hash_key, and sort key range in [start_sort_key, stop_sort_key) as default.
- :param hash_key: (str) which hash key used for this API.
- :param start_sort_key: (str) returned k-v pairs is start from start_sort_key.
- :param stop_sort_key: (str) returned k-v pairs is stop at stop_sort_key.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param start_sort_key: (bytes) returned k-v pairs is start from start_sort_key.
+ :param stop_sort_key: (bytes) returned k-v pairs is stop at stop_sort_key.
:param multi_get_options: (MultiGetOptions) configurable multi_get options.
:param max_kv_count: (int) max count of k-v pairs to be fetched. max_fetch_count <= 0 means no limit.
:param max_kv_size: (int) max total data size of k-v pairs to be fetched. max_fetch_size <= 0 means no limit.
@@ -313,8 +315,8 @@ def remove(self, hash_key, sort_key, timeout=0):
"""
Remove the entire <hash_key, sort_key>-value in pegasus.
- :param hash_key: (str) which hash key used for this API.
- :param sort_key: (str) which sort key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param sort_key: (bytes) which sort key used for this API.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
@@ -333,7 +335,7 @@ def multi_del(self, hash_key, sortkey_set, timeout=0):
"""
Remove multiple entire <hash_key, sort_key>-values in pegasus.
- :param hash_key: (str) which hash key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
:param sortkey_set: (set) sort keys in set.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
@@ -353,7 +355,7 @@ def sort_key_count(self, hash_key, timeout=0):
"""
Get the total sort key count under the hash_key.
- :param hash_key: (str) which hash key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
:param timeout: (int) how long will the operation timeout in milliseconds.
if timeout > 0, it is a timeout value for current operation,
else the timeout value specified to create the instance will be used.
@@ -375,7 +377,7 @@ def get_sort_keys(self, hash_key,
"""
Get multiple sort keys under hash_key.
- :param hash_key: (str) which hash key used for this API.
+ :param hash_key: (bytes) which hash key used for this API.
:param max_kv_count: (int) max count of k-v pairs to be fetched. max_fetch_count <= 0 means no limit.
:param max_kv_size: (int) max total data size of k-v pairs to be fetched. max_fetch_size <= 0 means no limit.
:param timeout: (int) how long will the operation timeout in milliseconds.
@@ -383,7 +385,7 @@ def get_sort_keys(self, hash_key,
else the timeout value specified to create the instance will be used.
:return: (tuple<error_types.code.value, set>) (code, ks)
code: error_types.ERR_OK.value when data got succeed.
- ks: <sort_key, ign> pairs in dict, ign will always be empty str.
+ ks: <sort_key, ign> pairs in dict, ign will always be empty bytes.
"""
```
@@ -399,9 +401,9 @@ def get_scanner(self, hash_key,
Get scanner for hash_key, start from start_sort_key, and stop at stop_sort_key.
Whether the scanner include the start_sort_key and stop_sort_key is configurable by scan_options
- :param hash_key: (str) which hash key used for this API.
- :param start_sort_key: (str) returned scanner is start from start_sort_key.
- :param stop_sort_key: (str) returned scanner is stop at stop_sort_key.
+ :param hash_key: (bytes) which hash key used for this API.
+ :param start_sort_key: (bytes) returned scanner is start from start_sort_key.
+ :param stop_sort_key: (bytes) returned scanner is stop at stop_sort_key.
:param scan_options: (ScanOptions) configurable scan options.
:return: (PegasusScanner) scanner, instance of PegasusScanner.
"""
@@ -458,8 +460,7 @@ class PegasusScanner(object):
def get_next(self):
"""
scan the next k-v pair for the scanner.
-
:return: (tuple<tuple<hash_key, sort_key>, value> or None)
- all the sort_keys returned by this API are in ascend order.
+ all the sort_keys returned by this API are in ascend order.
"""
```
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org