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 b85e986
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 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

0 comments on commit b85e986

Please sign in to comment.