Skip to content

Commit 9f2e05f

Browse files
committed
chore: update
1 parent 04a2173 commit 9f2e05f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docker-compose/local/infra-mq-nats.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ services:
2727
image: nats:alpine3.20
2828
container_name: nats
2929
restart: unless-stopped
30-
command: [ "-js" ] # TODO X: 启用 JetStream
30+
command: [
31+
"-js", # TODO X: 启用 JetStream
32+
"-m", "8222" # 启用 HTTP 监控并指定端口
33+
]
3134
ports:
3235
- '4222:4222'
3336
- '6222:6222'
3437
- '8222:8222'
3538

39+
volumes:
40+
- nats_data:/data
41+
3642
networks:
3743
- nats_net
3844

@@ -45,4 +51,6 @@ services:
4551
networks:
4652
nats_net:
4753

48-
54+
# 自定义数据卷:
55+
volumes:
56+
nats_data:

packages/try-nats/py/src/try_nats/run_kv.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ async def main():
1515
# Create a KV
1616
kv = await js.create_key_value(bucket='MY_KV')
1717

18+
for i in range(5):
19+
await kv.put(f'key_{i}', b'value_{i}')
20+
1821
# Set and retrieve a value
1922
await kv.put('hello', b'world')
2023
entry = await kv.get('hello')
21-
print(f'KeyValue.Entry: key={entry.key}, value={entry.value}')
24+
logger.debug(f'KeyValue.Entry: key={entry.key}, value={entry.value}')
2225
# KeyValue.Entry: key=hello, value=world
2326

27+
logger.debug(f"kv: {await kv.status()}")
28+
2429
await nc.close()
2530

2631

0 commit comments

Comments
 (0)