Skip to content

Commit

Permalink
CP-26352 Port xcp-idl/network interface from Camlp4 to PPX
Browse files Browse the repository at this point in the history
1. all types deriving from rpcty
2. remove redundent rpc functions, replace them with `@@default` rewriter
3. rename `Basic` of `string_of_port_kind` to `Basic_port`
4. change type `ipv4_route_t` from list to a struct type
5. move exception definition to xcp-networkd
6. declare interface with new style code by using `Idl.declare`
7. replace optional parameter with position parameter or position option
parameter, remove the redundent suffix unit parameter accordingly
8. replace `rpc_of_x` and `x_of_rpc` with `Rpcmarshal.marshal` and `Rpamarshal.unmarshal`
9. update jbuilder file, remove redundant contents

Signed-off-by: Yang Qian <yang.qian@citrix.com>
  • Loading branch information
krizex authored and Marcello Seri committed Feb 27, 2018
1 parent 2849faa commit b23a13d
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 247 deletions.
25 changes: 5 additions & 20 deletions network/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,27 @@ let flags = function
in
go ic ""

let rewriters_ppx = ["ppx_deriving_rpc"]

let coverage_rewriter =
let is_coverage = try Unix.getenv "BISECT_ENABLE" = "YES" with Not_found -> false in
if is_coverage then
"(preprocess (pps (bisect_ppx -conditional)))"
else
""

let rewriters_camlp4 = ["rpclib.idl -syntax camlp4o"]
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv"]
Printf.sprintf "(preprocess (pps (%s)))" (String.concat " " rewriters_ppx)

let () = Printf.ksprintf Jbuild_plugin.V1.send {|
(jbuild_version 1)

(library
((name xcp_network_interface)
(public_name xcp.network.interface)
(modules (network_interface))
(flags (:standard -w -39 %s))
(libraries
(rpclib
threads
xcp))
(wrapped false)
%s))

(library
((name xcp_network)
(public_name xcp.network)
(modules (:standard \ network_interface))
(flags (:standard -w -39-33 %s))
(libraries
(rpclib
threads
xcp
xcp_network_interface))
xcp))
(wrapped false)
%s))

|} (flags rewriters_camlp4) coverage_rewriter (flags rewriters_ppx) coverage_rewriter
|} (flags rewriters_ppx) coverage_rewriter
29 changes: 13 additions & 16 deletions network/network_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* GNU Lesser General Public License for more details.
*)

open Network_interface
open Xcp_client

let retry_econnrefused f =
let rec loop () =
let result =
Expand All @@ -28,16 +25,16 @@ let retry_econnrefused f =
| None -> loop () in
loop ()

module Client = Network_interface.Client(struct
let rpc call =
retry_econnrefused
(fun () ->
if !use_switch
then json_switch_rpc !queue_name call
else xml_http_rpc
~srcstr:(Xcp_client.get_user_agent ())
~dststr:"network"
Network_interface.uri
call
)
end)
let rpc call =
retry_econnrefused
(fun () ->
if !Xcp_client.use_switch
then Xcp_client.json_switch_rpc !Network_interface.queue_name call
else Xcp_client.xml_http_rpc
~srcstr:(Xcp_client.get_user_agent ())
~dststr:"network"
Network_interface.uri
call
)

module Client = Network_interface.Interface_API(Idl.GenClientExnRpc(struct let rpc=rpc end))
Loading

0 comments on commit b23a13d

Please sign in to comment.