Skip to content

Commit d291e58

Browse files
committed
update readme with better app example
1 parent 51e8184 commit d291e58

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,32 @@ The easiest way to do this is to initialize ChordNet as an attribute on
4141
an application class:
4242
```python
4343
class App:
44+
"""An example/template application that uses ChordNet."""
4445
def __init__(self, ip: str, chordnet_port: int) -> None:
46+
"""Creates a new insance of the app."""
4547
self._ring = ChordNet(ip, chordnet_port)
4648

4749
def start(
4850
self, ip = None: str | None, port = None: int | None
4951
) -> None:
52+
"""Starts the app by joining an existing ring or creating a new one."""
5053
if ip and port:
5154
self._ring.join(ip, port)
55+
# ...any state transfer logic, if part of this app...
5256
elif not ip and not port:
5357
self._ring.create()
5458
else:
5559
print("need both or neither")
5660
return
61+
62+
#...application logic (probably using self._ring.lookup()...
63+
5764
def stop(self) -> None:
65+
"""Gracefully leaves the ring."""
66+
# ...any state transfer logic (if using)...
5867
self._ring.leave()
5968
```
60-
In future versions, we hope to support in-package state transfer.
69+
Not all distributed applications that ChordNet is suitable for will require
70+
state transfer logic (for example, search problems), and the nature of that
71+
logic will likely vary by app. In future versions, we hope to support
72+
in-library state transfer.

0 commit comments

Comments
 (0)