Skip to content

Commit 33b8557

Browse files
authored
Merge pull request #62 from matburt/message_info_return
Return message id when sending from the Controller api
2 parents d176eee + f1d8f2f commit 33b8557

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

receptor/controller.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ async def recv(self):
4141
return inner.raw_payload
4242

4343
async def send(self, message, expect_response=True):
44+
new_id = uuid.uuid4()
4445
inner_env = envelope.Inner(
4546
receptor=self.receptor,
46-
message_id=str(uuid.uuid4()),
47+
message_id=str(new_id),
4748
sender=self.receptor.node_id,
4849
recipient=message.recipient,
4950
message_type="directive",
@@ -52,9 +53,10 @@ async def send(self, message, expect_response=True):
5253
raw_payload=message.fd.read(),
5354
)
5455
await self.receptor.router.send(inner_env, expected_response=expect_response)
56+
return new_id
5557

5658
async def ping(self, destination, expected_response=True):
57-
await self.receptor.router.ping_node(destination, expected_response)
59+
return await self.receptor.router.ping_node(destination, expected_response)
5860

5961
def run(self, app=None):
6062
try:

receptor/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async def ping_node(self, node_id, expected_response=True):
9696
directive='receptor:ping',
9797
ttl=15
9898
)
99-
await self.send(ping_envelope, expected_response)
99+
return await self.send(ping_envelope, expected_response)
100100

101101
def find_shortest_path(self, to_node_id):
102102
"""Implementation of Dijkstra algorithm"""

0 commit comments

Comments
 (0)