Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ sn list-swarms --seconds 5
See [`examples/`](./examples).

```bash
# smallest RPC example
python examples/basic_rpc/node.py
python examples/basic_rpc/client.py

# two nodes, one delegates to the other
python examples/isolated_agents/agent_alpha.py
python examples/isolated_agents/agent_beta.py
Expand Down
17 changes: 0 additions & 17 deletions example_node.py

This file was deleted.

4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ sn list-swarms
## 1. Basic node RPC

```bash
python example_node.py
python example_client.py
python basic_rpc/node.py
python basic_rpc/client.py
```

A node exposes `sum`. A client calls it.
Expand Down
2 changes: 1 addition & 1 deletion example_client.py → examples/basic_rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

async def main() -> None:
result = await Client("127.0.0.1", 9999).call("sum", 1, 2)
print(f"Received: {result}")
print(f"sum(1, 2) = {result}")


if __name__ == "__main__":
Expand Down
12 changes: 12 additions & 0 deletions examples/basic_rpc/node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from synapse_p2p import Node

node = Node(name="calculator", port=9999)


@node.endpoint("sum", description="Add two numbers")
async def sum_endpoint(a: int, b: int) -> int:
return a + b


if __name__ == "__main__":
node.run()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ asyncio_mode = "auto"
testpaths = ["synapse_p2p/tests"]

[tool.pyrefly]
project-includes = ["synapse_p2p", "examples", "example_client.py", "example_node.py"]
project-includes = ["synapse_p2p", "examples"]
project-excludes = ["**/__pycache__", ".venv", ".ruff_cache", ".pytest_cache"]
Loading