TODO desc
Types
RPCMethod* = proc (args: openArray[Msg]): Msg
Server* = object sock: AsyncSocket methods: TableRef[string, RPCMethod]
SocketAllocFn* = proc (): AsyncSocket
SocketPool* = ref object lock: TLock allocFn: SocketAllocFn free: seq[AsyncSocket] used: seq[AsyncSocket]
MultiFuture* = ref object lock: TLock futs: seq[Future[Msg]] finFuts: seq[Msg] pool: SocketPool
Procs
proc newServer*(sock: AsyncSocket): Server
proc addMethod*(server: var Server; name: string; f: RPCMethod)
proc run*(server: Server) {.async.}
proc newClient*(sock: AsyncSocket): Client
proc call*(cli: Client; id: int; name: string; args: seq[Msg]): Future[Msg] {. async.}
proc newSocketPool*(f: SocketAllocFn): SocketPool
proc size*(pool: var SocketPool): int
proc join*(mfut: MultiFuture): seq[Msg]
- Wait for all requests and the results in-order.
proc newMultiFuture*(pool: SocketPool): MultiFuture
proc add*(mfut: MultiFuture; name: string; args: seq[Msg])
- Add a new future