relays: add resolve proc

This commit is contained in:
Emery Hemingway 2023-10-13 23:36:34 +01:00
parent 6fcb76b1e9
commit 3a04fc195b
2 changed files with 16 additions and 1 deletions

View File

@ -416,3 +416,18 @@ when defined(posix):
dispatch(relay, pr)
asyncStdin.read(stdinReadSize).addCallback(readCb)
asyncStdin.read(stdinReadSize).addCallback(readCb)
type BootProc* = proc (turn: var Turn; ds: Cap) {.gcsafe.}
proc resolve*(turn: var Turn; route: Route; bootProc: BootProc) =
var
unix: Unix
tcp: Tcp
if route.transports.len != 1 or route.pathSteps.len != 1:
raise newException(ValueError, "only a single transport and step supported for routes")
if unix.fromPreserve route.transports[0]:
connect(turn, unix, route.pathSteps[0], bootProc)
elif tcp.fromPreserve route.transports[0]:
connect(turn, tcp, route.pathSteps[0], bootProc)
else:
raise newException(ValueError, "unsupported route")

View File

@ -1,6 +1,6 @@
# Package
version = "20231005"
version = "20231013"
author = "Emery Hemingway"
description = "Syndicated actors for conversational concurrency"
license = "Unlicense"