Skip to content

Commit

Permalink
feat: add pull_kvs method
Browse files Browse the repository at this point in the history
  • Loading branch information
ifooth committed Dec 5, 2024
1 parent f7a84db commit 88fcebd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bk_bscp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ def pull_kvs(self, app: str, match: List[str], app_options: Optional[AppOptions]
uid = self._fingerprint

if app_options is not None:
uid = app_options.uid
uid = app_options.uid or self._fingerprint
total_labels = {**self.labels, **(app_options.labels or {})}
match = [*match, *(app_options.match or [])]

msg = feed_server_pb2.PullKvMetaReq(
match=match,
Expand Down
10 changes: 8 additions & 2 deletions examples/get_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# to the current version of the project delivered to anyone in the future.
"""Get a key."""

from bk_bscp.client import BscpClient
from bk_bscp.client import AppOptions, BscpClient

SERVER_ADDRS = ["example.com:9090"]
TOKEN = "your_token"
Expand All @@ -29,8 +29,14 @@ def get_key():


def get_all_keys():
app = AppOptions(
match=[],
labels={},
uid="",
)

with BscpClient(SERVER_ADDRS, TOKEN, BIZ_ID) as client:
release = client.pull_kvs("app1", ["key1"])
release = client.pull_kvs("app1", ["key1"], app)
for kv in release.kvs:
pair = client.get("app1", kv.key)
print(pair)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ with BscpClient(server_addrs, token, biz_id) as client:
安装环境

```bash
# 安装版本, 修改{version}为版本好, 如3.18, 如果已经有版本,步骤忽略
# 安装版本, 修改{version}为版本号, 如3.18, 如果已经有版本,步骤忽略
uv python install {version}

# 创建环境, 修改{path}为python真实路径
Expand Down
2 changes: 1 addition & 1 deletion readme_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ For more sample code, please refer to the examples/ directory.
Installation environment

```bash
# Install version, modify {version} to a good version, such as 3.18. If there is already a version, ignore this step
# Install version, modify {version} to real version, such as 3.18. If there is already a version, ignore this step
uv python install {version}

# Create environment, modify {path} to the real path of python
Expand Down

0 comments on commit 88fcebd

Please sign in to comment.