Commit 3d5fc91
authored
Implement distributed reply channels for remote await (#169)
* Implement distributed reply channels for remote await
Add a request-response protocol over the mesh so that
`await actor.method()` on a remote actor returns the actual
reply instead of falling back to fire-and-forget.
Wire protocol:
- Extend HewWireEnvelope with request_id (field 5, varint) and
source_node_id (field 6, varint). Fields are only encoded when
non-zero, preserving backward compatibility with existing nodes.
Reply routing table (hew_node.rs):
- Process-global HashMap<u64, Arc<PendingReply>> keyed by request_id.
- Atomic u64 counter for unique request ID generation.
- Condvar-based blocking with timeout for the calling thread.
Outbound remote ask (hew_node_api_ask):
- If local PID: delegates to hew_actor_ask_by_id (new).
- If remote PID: registers pending reply, sends envelope with
request_id and source_node_id, blocks on condvar (5s timeout),
returns reply data or zeroed fallback buffer.
Inbound ask handling (node_inbound_router):
- Detects request_id > 0 with source_node_id > 0.
- Spawns a thread to perform a local blocking ask via
hew_actor_ask_by_id, then sends the reply envelope back.
Reply receipt (reader_loop in connection.rs):
- Detects reply envelopes (request_id > 0, source_node_id == 0).
- Deposits payload in the reply routing table, signalling the
condvar to wake the blocked caller.
Codegen (codegen.cpp ActorAskOpLowering):
- Remote i64 targets now call hew_node_api_ask instead of
hew_actor_send_by_id, enabling actual return values.
New runtime helpers:
- hew_actor_ask_by_id: blocking ask by actor ID (not pointer).
- hew_reply_wait_with_size: returns both value and size.
- InboundRouter extended to 6 params (+ request_id, source_node_id).
Tests:
- Wire envelope roundtrip with request_id/source_node_id.
- Backward compatibility (fields default to zero).
- Reply routing table: register, complete, remove, concurrent wake.
Closes #165
* Fix unclosed mod tests delimiter from merge conflict
The merge of main into issue-165-remote-await lost the closing brace
for the mod tests block, causing the Node API wrapper functions and
reply table code to be parsed inside the test module. This produced
an 'unclosed delimiter' error on all CI platforms.1 parent 5995696 commit 3d5fc91
7 files changed
Lines changed: 944 additions & 97 deletions
File tree
- hew-codegen/src
- hew-runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
969 | 969 | | |
970 | 970 | | |
971 | 971 | | |
972 | | - | |
973 | | - | |
974 | | - | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
975 | 975 | | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
981 | 982 | | |
982 | | - | |
983 | 983 | | |
984 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
985 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
986 | 992 | | |
987 | 993 | | |
988 | | - | |
989 | | - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
990 | 1009 | | |
991 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
992 | 1014 | | |
993 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
994 | 1023 | | |
995 | 1024 | | |
996 | 1025 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1372 | 1372 | | |
1373 | 1373 | | |
1374 | 1374 | | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
1375 | 1487 | | |
1376 | 1488 | | |
1377 | 1489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
198 | 202 | | |
199 | 203 | | |
200 | 204 | | |
| |||
673 | 677 | | |
674 | 678 | | |
675 | 679 | | |
| 680 | + | |
| 681 | + | |
676 | 682 | | |
677 | 683 | | |
678 | 684 | | |
| |||
892 | 898 | | |
893 | 899 | | |
894 | 900 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
901 | 925 | | |
902 | 926 | | |
903 | 927 | | |
| |||
1157 | 1181 | | |
1158 | 1182 | | |
1159 | 1183 | | |
| 1184 | + | |
1160 | 1185 | | |
1161 | 1186 | | |
1162 | 1187 | | |
| |||
0 commit comments