Hi all I’m trying to get my head around how the Async ecosystem connects together.
I’m aiming to have a persistant rpc connection to some set of services. I can see that there is a way to create persistant connections: Persistant_connection_kernel, however it isn’t obvious to me how use that, and additionally how to inject the result into the rpc connection system: Rpc.Connection.create.
I can see that there is an create method which takes a Transport.t though I can’t quite see how to pipe everything through (additionally it looks like there are two create methods which should alias each other?)
Async_rpc_kernel.Persistent_connection.Rpc is a pre-packaged persistent connection module which gives you Rpc.Connection.ts. It uses Host_and_port.t as the address type and Rpc.Connection.t as the connection type.
For example, you could do something like:
let _ =
let persistent_connection =
Async_rpc_kernel.Persistent_connection.Rpc.create
~server_name:"RPC server"
~connect:(fun host_and_port ->
Rpc.Connection.client
(Tcp.Where_to_connect.of_host_and_port host_and_port))
(fun () -> server_address)
in
let%bind conn = Async_rpc_kernel.Persistent_connection.Rpc.connected persistent_connection in
(* do something with the RPC connection *)