Skip to content

Commit 56af044

Browse files
updated documentaion
1 parent 52876a0 commit 56af044

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

node/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ await mesh.start();
4141
Register a service name to handle incoming connections.
4242

4343
```typescript
44-
await mesh.registerService('my-service-name', {
44+
mesh.registerService('my-service-name')
4545
// 1. Streaming Handler
46-
onRequestChannel: async (channel) => {
46+
.onRequestChannel(async (channel) => {
4747
console.log(`Accepted connection`);
4848
try {
4949
for await (const msg of channel) {
@@ -53,13 +53,12 @@ await mesh.registerService('my-service-name', {
5353
} catch (e) {
5454
console.error(e);
5555
}
56-
},
56+
})
5757
// 2. Unary Handler (Request/Reply)
58-
onRequestReply: async (msg) => {
58+
.onRequestReply(async (msg) => {
5959
console.log('Received Unary:', msg.payload);
6060
return { function_name: 'reply', payload: 'Got Unary!' };
61-
}
62-
});
61+
});
6362
```
6463

6564
### 4. Connect to a Peer (Client)

python/README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,22 @@ Register a service name to handle incoming connections.
5252

5353
```python
5454
async def stream_handler(channel):
55-
print("Accepted connection")
5655
print("Accepted connection")
5756
try:
5857
async for msg in channel:
59-
print(f"Received: {msg.payload}")
60-
response = Message(function_name="reply", payload="Got it!")
58+
print(f"Received: {msg['payload']}")
59+
response = {"function_name": "reply", "payload": "Got it!"}
6160
await channel.send(response)
6261
except Exception:
6362
pass
6463

6564
async def unary_handler(msg):
66-
print(f"Received Unary: {msg.payload}")
67-
return Message(function_name="reply", payload="Got Unary!")
65+
print(f"Received Unary: {msg['payload']}")
66+
return {"function_name": "reply", "payload": "Got Unary!"}
6867

69-
await mesh.register_service("my-service-name",
70-
on_request_channel=stream_handler,
71-
on_request_reply=unary_handler
72-
)
68+
mesh.register_service("my-service-name") \
69+
.on_request_channel(stream_handler) \
70+
.on_request_reply(unary_handler)
7371
```
7472

7573
### 4. Connect to a Peer (Client)
@@ -78,13 +76,13 @@ Discover and connect to another service.
7876
```python
7977
channel = await mesh.service("target-service-name").request_channel("session-id-123")
8078

81-
out_msg = Message(function_name="greet", payload="Hello World")
79+
out_msg = {"function_name": "greet", "payload": "Hello World"}
8280
await channel.send(out_msg)
8381

8482
# Reading messages (Async Iterator handles backpressure)
8583
async for msg in channel:
86-
print(f"Reply: {msg.payload}")
87-
if msg.payload == "Hello World": break # Exit loop to close
84+
print(f"Reply: {msg['payload']}")
85+
if msg['payload'] == "Hello World": break # Exit loop to close
8886

8987
await channel.close()
9088
```

0 commit comments

Comments
 (0)