Skip to content

Commit 1cfaab9

Browse files
authored
CP-307947: [maintenance]: add .mli files to all database modules (#6460)
ocaml-lsp-server's 'Action->Infer interface' was used for this, and then removed internal/unused entries. Having an mli file is useful: * can find dead code more easily if it is clear which functions are internal to a module and which aren't * the impact of refactoring changes is more obvious (did we have to change an mli at all?) * makes it easier to understand what a module does There are some .ml files which only contain types, these are instead renamed to .mli and dune's `modules_without_implementation` feature is used. Executables get an empty .mli (recent versions of dune already do the equivalent of this, but this makes it more obvious). Drop code from .ml files that now show up as unused. Eventually we can also add some documentation, this will be done in followup PRs for new code.
2 parents 7f96ccd + 9392894 commit 1cfaab9

37 files changed

+1127
-162
lines changed

ocaml/database/block_device_io.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val timeout_error_msg : string
16+
17+
val not_enough_space_error_msg : string
18+
19+
val not_initialised_error_msg : string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)

ocaml/database/db_action_helper.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,5 @@ let __callback :
2020

2121
let events_register f = __callback := Some f
2222

23-
let events_unregister () = __callback := None
24-
2523
let events_notify ?snapshot ty op ref =
2624
match !__callback with None -> () | Some f -> f ?snapshot ty op ref
27-
28-
(*
29-
exception Db_set_or_map_parse_fail of string
30-
31-
let parse_sexpr s : SExpr.t list =
32-
match SExpr_TS.of_string s with
33-
| SExpr.Node xs -> xs
34-
| _ -> raise (Db_set_or_map_parse_fail s)
35-
*)

ocaml/database/db_action_helper.mli

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val events_register :
16+
(?snapshot:Rpc.t -> string -> string -> string -> unit) -> unit
17+
18+
val events_notify : ?snapshot:Rpc.t -> string -> string -> string -> unit

ocaml/database/db_cache.mli

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val get : Db_ref.t -> (module Db_interface.DB_ACCESS)
16+
17+
val apply_delta_to_cache : Redo_log.t -> Db_ref.t -> unit

ocaml/database/db_cache_test.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)

ocaml/database/db_connections.mli

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val get_dbs_and_gen_counts : unit -> (int64 * Parse_db_conf.db_connection) list
16+
17+
val choose :
18+
Parse_db_conf.db_connection list -> Parse_db_conf.db_connection option
19+
20+
val preferred_write_db : unit -> Parse_db_conf.db_connection
21+
22+
val exit_on_next_flush : bool ref
23+
24+
val inc_db_flush_thread_refcount : unit -> unit
25+
26+
val flush_dirty_and_maybe_exit :
27+
Parse_db_conf.db_connection -> int option -> bool
28+
29+
val flush : Parse_db_conf.db_connection -> Db_cache_types.Database.t -> unit

ocaml/database/db_exn.mli

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
(** class * field * uuid * key *)
16+
exception Duplicate_key of string * string * string * string
17+
18+
(** message * class * key *)
19+
exception DBCache_NotFound of string * string * string
20+
21+
(** class * field * key *)
22+
exception Uniqueness_constraint_violation of string * string * string
23+
24+
(** class * field * value *)
25+
exception Integrity_violation of string * string * string
26+
27+
(** class * _ * uuid *)
28+
exception Read_missing_uuid of string * string * string
29+
30+
(** class * _ * uuid *)
31+
exception Too_many_values of string * string * string
32+
33+
exception Remote_db_server_returned_unknown_exception
34+
35+
exception Remote_db_server_returned_bad_message
36+
37+
exception Empty_key_in_map
38+
39+
exception Invalid_value

ocaml/database/db_filter.ml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,6 @@
1818

1919
open Db_filter_types
2020

21-
let string_of_val = function
22-
| Field x ->
23-
"Field " ^ x
24-
| Literal x ->
25-
"Literal " ^ x
26-
27-
let rec string_of_expr =
28-
let binexpr name a b =
29-
Printf.sprintf "%s (%s, %s)" name (string_of_expr a) (string_of_expr b)
30-
in
31-
let binval name a b =
32-
Printf.sprintf "%s (%s, %s)" name (string_of_val a) (string_of_val b)
33-
in
34-
function
35-
| True ->
36-
"True"
37-
| False ->
38-
"False"
39-
| Not x ->
40-
Printf.sprintf "Not ( %s )" (string_of_expr x)
41-
| And (a, b) ->
42-
binexpr "And" a b
43-
| Or (a, b) ->
44-
binexpr "Or" a b
45-
| Eq (a, b) ->
46-
binval "Eq" a b
47-
4821
exception XML_unmarshall_error
4922

5023
let val_of_xml xml =

0 commit comments

Comments
 (0)