Skip to content

Commit

Permalink
Hide that get_records are stored in a Hashtbl
Browse files Browse the repository at this point in the history
Signed-off-by: Colin James <[email protected]>
  • Loading branch information
contificate committed Dec 18, 2024
1 parent cc50840 commit 4f87195
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions ocaml/idl/ocaml_backend/gen_db_actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ let db_action api : O.Module.t =
O.Let.make ~name:"_" ~params:[] ~ty:"unit"
~body:
[
Printf.sprintf "Hashtbl.add Eventgen.get_record_table \"%s\""
obj.DT.name
Printf.sprintf "Eventgen.set_get_record \"%s\"" obj.DT.name
; Printf.sprintf
"(fun ~__context ~self -> (fun () -> API.rpc_of_%s_t \
(%s.get_record ~__context ~self:(Ref.of_%sstring self))))"
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/eventgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ let get_record_table :
(string, __context:Context.t -> self:string -> get_record) Hashtbl.t =
Hashtbl.create 64

let set_get_record = Hashtbl.replace get_record_table

let find_get_record obj_name ~__context ~self () : Rpc.t option =
Option.map
(fun f -> f ~__context ~self ())
Expand Down
12 changes: 6 additions & 6 deletions ocaml/xapi/eventgen.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* GNU Lesser General Public License for more details.
*)

type get_record = unit -> Rpc.t

val get_record_table :
(string, __context:Context.t -> self:string -> get_record) Hashtbl.t

open Xapi_database.Db_cache_types

val database_callback : update -> Database.t -> unit
type get_record = unit -> Rpc.t

val set_get_record :
string -> (__context:Context.t -> self:string -> get_record) -> unit

val find_get_record :
string -> __context:Context.t -> self:string -> unit -> Rpc.t option

val database_callback : update -> Database.t -> unit

0 comments on commit 4f87195

Please sign in to comment.