Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
hhstore committed Jul 4, 2024
1 parent 04a2173 commit 9f2e05f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions docker-compose/local/infra-mq-nats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ services:
image: nats:alpine3.20
container_name: nats
restart: unless-stopped
command: [ "-js" ] # TODO X: 启用 JetStream
command: [
"-js", # TODO X: 启用 JetStream
"-m", "8222" # 启用 HTTP 监控并指定端口
]
ports:
- '4222:4222'
- '6222:6222'
- '8222:8222'

volumes:
- nats_data:/data

networks:
- nats_net

Expand All @@ -45,4 +51,6 @@ services:
networks:
nats_net:


# 自定义数据卷:
volumes:
nats_data:
7 changes: 6 additions & 1 deletion packages/try-nats/py/src/try_nats/run_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ async def main():
# Create a KV
kv = await js.create_key_value(bucket='MY_KV')

for i in range(5):
await kv.put(f'key_{i}', b'value_{i}')

# Set and retrieve a value
await kv.put('hello', b'world')
entry = await kv.get('hello')
print(f'KeyValue.Entry: key={entry.key}, value={entry.value}')
logger.debug(f'KeyValue.Entry: key={entry.key}, value={entry.value}')
# KeyValue.Entry: key=hello, value=world

logger.debug(f"kv: {await kv.status()}")

await nc.close()


Expand Down

0 comments on commit 9f2e05f

Please sign in to comment.