@@ -21,16 +21,40 @@ Fall 2024.
2121
2222
2323## Usage
24- to stay consistent with the language from the original paper, we recommend
24+ To stay consistent with the language from the original paper, we recommend
2525naming your chordnet attribute ` ring ` :
2626``` python
2727from chordnet import ChordNet
2828
2929ring = new ChordNet(... )
30- ring.create()
31- # or ring.join(...)
32- # ...
30+ ring.create() # or ring.join(...)
31+ # ...application logic...
3332ring.leave()
33+ # end program
3434```
3535This fits with the concept of "joining" an existing ring network, or creating a
3636new one. Examples follow this practice.
37+
38+ At present, this package only supports IP lookup. All application-dependent
39+ logic (state transfer, etc) must be handled by the application.
40+ The easiest way to do this is to initialize ChordNet as an attribute on
41+ an application class:
42+ ``` python
43+ class App :
44+ def __init__ (self , ip : str , chordnet_port : int ) -> None :
45+ self ._ring = ChordNet(ip, chordnet_port)
46+
47+ def start (
48+ self , ip = None : str | None , port = None : int | None
49+ ) -> None :
50+ if ip and port:
51+ self ._ring.join(ip, port)
52+ elif not ip and not port:
53+ self ._ring.create()
54+ else :
55+ print (" need both or neither" )
56+ return
57+ def stop (self ) -> None :
58+ self ._ring.leave()
59+ ```
60+ In future versions, we hope to support in-package state transfer.
0 commit comments