better command/response names: allocate+allocated, claim+claimed

This commit is contained in:
Brian Warner 2016-05-20 11:35:30 -07:00
parent 6c5b517ad1
commit 390cd08b53
2 changed files with 6 additions and 6 deletions

View File

@ -56,9 +56,9 @@ from .rendezvous import CrowdedError
# -> {type: "list"} -> nameplates
# <- {type: "nameplates", nameplates: [str..]}
# -> {type: "allocate"} -> nameplate, mailbox
# <- {type: "nameplate", nameplate: str}
# <- {type: "allocated", nameplate: str}
# -> {type: "claim", nameplate: str} -> mailbox
# <- {type: "mailbox", mailbox: str}
# <- {type: "claimed", mailbox: str}
# -> {type: "release"}
#
# -> {type: "open", mailbox: str} -> message
@ -160,7 +160,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
nameplate_id = self._app.allocate_nameplate(self._side, server_rx)
assert isinstance(nameplate_id, type(u""))
self._did_allocate = True
self.send("nameplate", nameplate=nameplate_id)
self.send("allocated", nameplate=nameplate_id)
def handle_claim(self, msg, server_rx):
if "nameplate" not in msg:
@ -173,7 +173,7 @@ class WebSocketRendezvous(websocket.WebSocketServerProtocol):
server_rx)
except CrowdedError:
raise Error("crowded")
self.send("mailbox", mailbox=mailbox_id)
self.send("claimed", mailbox=mailbox_id)
def handle_release(self, server_rx):
if not self._nameplate_id:

View File

@ -544,7 +544,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
app = self._rendezvous.get_app(u"appid")
c1.send(u"allocate")
m = yield c1.next_non_ack()
self.assertEqual(m[u"type"], u"nameplate")
self.assertEqual(m[u"type"], u"allocated")
nameplate_id = m[u"nameplate"]
nids = app.get_nameplate_ids()
@ -579,7 +579,7 @@ class WebSocketAPI(ServerBase, unittest.TestCase):
c1.send(u"claim", nameplate=u"np1")
m = yield c1.next_non_ack()
self.assertEqual(m[u"type"], u"mailbox")
self.assertEqual(m[u"type"], u"claimed")
mailbox_id = m[u"mailbox"]
self.assertEqual(type(mailbox_id), type(u""))