Client refactor: add calling function in Worker_services
This commit is contained in:
parent
1858bdd852
commit
0e675c2d16
@ -449,14 +449,14 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Prevalidators *)
|
(* Workers : Prevalidators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Prevalidators.list
|
RPC_directory.register0 dir Worker_services.Prevalidators.S.list
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.map
|
(List.map
|
||||||
(fun (id, w) -> (id, Prevalidator.status w))
|
(fun (id, w) -> (id, Prevalidator.status w))
|
||||||
(Prevalidator.running_workers ()))) in
|
(Prevalidator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Prevalidators.state
|
RPC_directory.register1 dir Worker_services.Prevalidators.S.state
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
let w = List.assoc net_id (Prevalidator.running_workers ()) in
|
let w = List.assoc net_id (Prevalidator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -468,7 +468,7 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Block_validator *)
|
(* Workers : Block_validator *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Block_validator.state
|
RPC_directory.register0 dir Worker_services.Block_validator.S.state
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
let w = Block_validator.running_worker () in
|
let w = Block_validator.running_worker () in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -480,7 +480,7 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Peer validators *)
|
(* Workers : Peer validators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Peer_validators.list
|
RPC_directory.register1 dir Worker_services.Peer_validators.S.list
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.filter_map
|
(List.filter_map
|
||||||
@ -490,7 +490,7 @@ let build_rpc_directory node =
|
|||||||
else None)
|
else None)
|
||||||
(Peer_validator.running_workers ()))) in
|
(Peer_validator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register2 dir Worker_services.Peer_validators.state
|
RPC_directory.register2 dir Worker_services.Peer_validators.S.state
|
||||||
(fun net_id peer_id () () ->
|
(fun net_id peer_id () () ->
|
||||||
let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in
|
let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -502,14 +502,14 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Net validators *)
|
(* Workers : Net validators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Net_validators.list
|
RPC_directory.register0 dir Worker_services.Net_validators.S.list
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.map
|
(List.map
|
||||||
(fun (id, w) -> (id, Net_validator.status w))
|
(fun (id, w) -> (id, Net_validator.status w))
|
||||||
(Net_validator.running_workers ()))) in
|
(Net_validator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Net_validators.state
|
RPC_directory.register1 dir Worker_services.Net_validators.S.state
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
let w = List.assoc net_id (Net_validator.running_workers ()) in
|
let w = List.assoc net_id (Net_validator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
|
@ -11,144 +11,162 @@ open Data_encoding
|
|||||||
|
|
||||||
module Prevalidators = struct
|
module Prevalidators = struct
|
||||||
|
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
module S = struct
|
||||||
RPC_arg.make
|
|
||||||
~name:"net_id"
|
|
||||||
~descr:"The network identifier of whom the prevalidator is responsible."
|
|
||||||
~destruct:(fun s -> try
|
|
||||||
Ok (Net_id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let list =
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
RPC_service.post_service
|
RPC_arg.like
|
||||||
~description:"Lists the Prevalidator workers and their status."
|
Net_id.rpc_arg
|
||||||
~query: RPC_query.empty
|
~descr:"The network identifier of whom the prevalidator is responsible."
|
||||||
~input: empty
|
"net_id"
|
||||||
~output:
|
|
||||||
(list
|
|
||||||
(obj2
|
|
||||||
(req "net_id" Net_id.encoding)
|
|
||||||
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
|
||||||
RPC_path.(root / "workers" / "prevalidators")
|
|
||||||
|
|
||||||
let state =
|
let list =
|
||||||
let open Data_encoding in
|
RPC_service.post_service
|
||||||
RPC_service.post_service
|
~description:"Lists the Prevalidator workers and their status."
|
||||||
~description:"Introspect the state of a prevalidator worker."
|
~query: RPC_query.empty
|
||||||
~query: RPC_query.empty
|
~input: empty
|
||||||
~input: empty
|
~output:
|
||||||
~output:
|
(list
|
||||||
(Worker_types.full_status_encoding
|
(obj2
|
||||||
Prevalidator_worker_state.Request.encoding
|
(req "net_id" Net_id.encoding)
|
||||||
Prevalidator_worker_state.Event.encoding
|
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
||||||
RPC_error.encoding)
|
RPC_path.(root / "workers" / "prevalidators")
|
||||||
RPC_path.(root / "workers" / "prevalidators" /: net_id_arg )
|
|
||||||
|
let state =
|
||||||
|
let open Data_encoding in
|
||||||
|
RPC_service.post_service
|
||||||
|
~description:"Introspect the state of a prevalidator worker."
|
||||||
|
~query: RPC_query.empty
|
||||||
|
~input: empty
|
||||||
|
~output:
|
||||||
|
(Worker_types.full_status_encoding
|
||||||
|
Prevalidator_worker_state.Request.encoding
|
||||||
|
Prevalidator_worker_state.Event.encoding
|
||||||
|
RPC_error.encoding)
|
||||||
|
RPC_path.(root / "workers" / "prevalidators" /: Net_id.rpc_arg )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt = make_call S.list ctxt () () ()
|
||||||
|
let state ctxt h = make_call1 S.state ctxt h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Block_validator = struct
|
module Block_validator = struct
|
||||||
|
|
||||||
let state =
|
module S = struct
|
||||||
let open Data_encoding in
|
|
||||||
RPC_service.post_service
|
let state =
|
||||||
~description:"Introspect the state of the block_validator worker."
|
let open Data_encoding in
|
||||||
~query: RPC_query.empty
|
RPC_service.post_service
|
||||||
~input: empty
|
~description:"Introspect the state of the block_validator worker."
|
||||||
~output:
|
~query: RPC_query.empty
|
||||||
(Worker_types.full_status_encoding
|
~input: empty
|
||||||
Block_validator_worker_state.Request.encoding
|
~output:
|
||||||
Block_validator_worker_state.Event.encoding
|
(Worker_types.full_status_encoding
|
||||||
RPC_error.encoding)
|
Block_validator_worker_state.Request.encoding
|
||||||
RPC_path.(root / "workers" / "block_validator")
|
Block_validator_worker_state.Event.encoding
|
||||||
|
RPC_error.encoding)
|
||||||
|
RPC_path.(root / "workers" / "block_validator")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let state ctxt = make_call S.state ctxt () () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Peer_validators = struct
|
module Peer_validators = struct
|
||||||
|
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
module S = struct
|
||||||
RPC_arg.make
|
|
||||||
~name:"net_id"
|
|
||||||
~descr:"The network identifier the peer validator is associated to."
|
|
||||||
~destruct:(fun s -> try
|
|
||||||
Ok (Net_id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) =
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
RPC_arg.make
|
RPC_arg.like
|
||||||
~name:"peer_id"
|
Net_id.rpc_arg
|
||||||
~descr:"The peer identifier of whom the prevalidator is responsible."
|
~descr:"The network identifier the peer validator is associated to."
|
||||||
~destruct:(fun s -> try
|
"net_id"
|
||||||
Ok (P2p_peer.Id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:P2p_peer.Id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let list =
|
let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) =
|
||||||
RPC_service.post_service
|
RPC_arg.make
|
||||||
~description:"Lists the peer validator workers and their status."
|
~name:"peer_id"
|
||||||
~query: RPC_query.empty
|
~descr:"The peer identifier of whom the prevalidator is responsible."
|
||||||
~input: empty
|
~destruct:(fun s -> try
|
||||||
~output:
|
Ok (P2p_peer.Id.of_b58check_exn s)
|
||||||
(list
|
with Failure msg -> Error msg)
|
||||||
(obj2
|
~construct:P2p_peer.Id.to_b58check
|
||||||
(req "peer_id" P2p_peer.Id.encoding)
|
()
|
||||||
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
|
||||||
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg)
|
|
||||||
|
|
||||||
let state =
|
let list =
|
||||||
let open Data_encoding in
|
RPC_service.post_service
|
||||||
RPC_service.post_service
|
~description:"Lists the peer validator workers and their status."
|
||||||
~description:"Introspect the state of a peer validator worker."
|
~query: RPC_query.empty
|
||||||
~query: RPC_query.empty
|
~input: empty
|
||||||
~input: empty
|
~output:
|
||||||
~output:
|
(list
|
||||||
(Worker_types.full_status_encoding
|
(obj2
|
||||||
Peer_validator_worker_state.Request.encoding
|
(req "peer_id" P2p_peer.Id.encoding)
|
||||||
Peer_validator_worker_state.Event.encoding
|
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
||||||
RPC_error.encoding)
|
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg)
|
||||||
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg)
|
|
||||||
|
let state =
|
||||||
|
let open Data_encoding in
|
||||||
|
RPC_service.post_service
|
||||||
|
~description:"Introspect the state of a peer validator worker."
|
||||||
|
~query: RPC_query.empty
|
||||||
|
~input: empty
|
||||||
|
~output:
|
||||||
|
(Worker_types.full_status_encoding
|
||||||
|
Peer_validator_worker_state.Request.encoding
|
||||||
|
Peer_validator_worker_state.Event.encoding
|
||||||
|
RPC_error.encoding)
|
||||||
|
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt n = make_call1 S.list ctxt n () ()
|
||||||
|
let state ctxt n h = make_call2 S.state ctxt n h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Net_validators = struct
|
module Net_validators = struct
|
||||||
|
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
module S = struct
|
||||||
RPC_arg.make
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
~name:"net_id"
|
RPC_arg.like
|
||||||
~descr:"The network identifier of whom the net validator is responsible."
|
Net_id.rpc_arg
|
||||||
~destruct:(fun s -> try
|
~descr:"The network identifier of whom the net validator is responsible."
|
||||||
Ok (Net_id.of_b58check_exn s)
|
"net_id"
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let list =
|
let list =
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
~description:"Lists the net validator workers and their status."
|
~description:"Lists the net validator workers and their status."
|
||||||
~query: RPC_query.empty
|
~query: RPC_query.empty
|
||||||
~input: empty
|
~input: empty
|
||||||
~output:
|
~output:
|
||||||
(list
|
(list
|
||||||
(obj2
|
(obj2
|
||||||
(req "net_id" Net_id.encoding)
|
(req "net_id" Net_id.encoding)
|
||||||
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
(req "status" (Worker_types.worker_status_encoding RPC_error.encoding))))
|
||||||
RPC_path.(root / "workers" / "net_validators")
|
RPC_path.(root / "workers" / "net_validators")
|
||||||
|
|
||||||
let state =
|
let state =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
~description:"Introspect the state of a net validator worker."
|
~description:"Introspect the state of a net validator worker."
|
||||||
~query: RPC_query.empty
|
~query: RPC_query.empty
|
||||||
~input: empty
|
~input: empty
|
||||||
~output:
|
~output:
|
||||||
(Worker_types.full_status_encoding
|
(Worker_types.full_status_encoding
|
||||||
Net_validator_worker_state.Request.encoding
|
Net_validator_worker_state.Request.encoding
|
||||||
Net_validator_worker_state.Event.encoding
|
Net_validator_worker_state.Event.encoding
|
||||||
RPC_error.encoding)
|
RPC_error.encoding)
|
||||||
RPC_path.(root / "workers" / "net_validators" /: net_id_arg )
|
RPC_path.(root / "workers" / "net_validators" /: net_id_arg )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt = make_call S.list ctxt () () ()
|
||||||
|
let state ctxt h = make_call1 S.state ctxt h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -7,19 +7,30 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
|
||||||
module Prevalidators : sig
|
module Prevalidators : sig
|
||||||
|
|
||||||
open Prevalidator_worker_state
|
open Prevalidator_worker_state
|
||||||
|
|
||||||
val list :
|
val list:
|
||||||
([ `POST ], unit,
|
#simple -> (Net_id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
unit, unit, unit,
|
val state:
|
||||||
(Net_id.t * Worker_types.worker_status) list) RPC_service.t
|
#simple -> Net_id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
val state :
|
module S : sig
|
||||||
([ `POST ], unit,
|
|
||||||
unit * Net_id.t, unit, unit,
|
val list :
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
([ `POST ], unit,
|
||||||
|
unit, unit, unit,
|
||||||
|
(Net_id.t * Worker_types.worker_status) list) RPC_service.t
|
||||||
|
|
||||||
|
val state :
|
||||||
|
([ `POST ], unit,
|
||||||
|
unit * Net_id.t, unit, unit,
|
||||||
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -27,10 +38,17 @@ module Block_validator : sig
|
|||||||
|
|
||||||
open Block_validator_worker_state
|
open Block_validator_worker_state
|
||||||
|
|
||||||
val state :
|
val state:
|
||||||
([ `POST ], unit,
|
#simple -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
unit, unit, unit,
|
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
module S : sig
|
||||||
|
|
||||||
|
val state :
|
||||||
|
([ `POST ], unit,
|
||||||
|
unit, unit, unit,
|
||||||
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,15 +56,27 @@ module Peer_validators : sig
|
|||||||
|
|
||||||
open Peer_validator_worker_state
|
open Peer_validator_worker_state
|
||||||
|
|
||||||
val list :
|
val list:
|
||||||
([ `POST ], unit,
|
#simple -> Net_id.t ->
|
||||||
unit * Net_id.t, unit, unit,
|
(P2p_peer.Id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
(P2p_peer.Id.t * Worker_types.worker_status) list) RPC_service.t
|
|
||||||
|
|
||||||
val state :
|
val state:
|
||||||
([ `POST ], unit,
|
#simple ->
|
||||||
(unit * Net_id.t) * P2p_peer.Id.t, unit, unit,
|
Net_id.t -> P2p_peer.Id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
|
val list :
|
||||||
|
([ `POST ], unit,
|
||||||
|
unit * Net_id.t, unit, unit,
|
||||||
|
(P2p_peer.Id.t * Worker_types.worker_status) list) RPC_service.t
|
||||||
|
|
||||||
|
val state :
|
||||||
|
([ `POST ], unit,
|
||||||
|
(unit * Net_id.t) * P2p_peer.Id.t, unit, unit,
|
||||||
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,14 +84,23 @@ module Net_validators : sig
|
|||||||
|
|
||||||
open Net_validator_worker_state
|
open Net_validator_worker_state
|
||||||
|
|
||||||
val list :
|
val list:
|
||||||
([ `POST ], unit,
|
#simple -> (Net_id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
unit, unit, unit,
|
val state:
|
||||||
(Net_id.t * Worker_types.worker_status) list) RPC_service.t
|
#simple -> Net_id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
val state :
|
module S : sig
|
||||||
([ `POST ], unit,
|
|
||||||
unit * Net_id.t, unit, unit,
|
val list :
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
([ `POST ], unit,
|
||||||
|
unit, unit, unit,
|
||||||
|
(Net_id.t * Worker_types.worker_status) list) RPC_service.t
|
||||||
|
|
||||||
|
val state :
|
||||||
|
([ `POST ], unit,
|
||||||
|
unit * Net_id.t, unit, unit,
|
||||||
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user