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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)
+19
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
+1
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

-11
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

+18
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

+17
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

+1
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

+29
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

+39
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

-27
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 =

ocaml/database/db_filter.mli

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
exception XML_unmarshall_error
16+
17+
exception Expression_error of (string * exn)
18+
19+
val expr_of_xml : XMLRPC.xmlrpc -> Db_filter_types.expr
20+
21+
val expr_of_string : string -> Db_filter_types.expr
22+
23+
val xml_of_expr : Db_filter_types.expr -> XMLRPC.xmlrpc
24+
25+
val eval_expr : (Db_filter_types._val -> string) -> Db_filter_types.expr -> bool

ocaml/database/db_filter_lex.mli

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 lexer : Lexing.lexbuf -> Db_filter_parse.token

ocaml/database/db_filter_types.mli

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
type _val = Field of string | Literal of string
16+
17+
val rpc_of__val : _val -> Rpc.t
18+
19+
val _val_of_rpc : Rpc.t -> _val
20+
21+
type expr =
22+
| True
23+
| False
24+
| Not of expr
25+
| Eq of _val * _val
26+
| And of expr * expr
27+
| Or of expr * expr
28+
29+
val rpc_of_expr : expr -> Rpc.t
30+
31+
val expr_of_rpc : Rpc.t -> expr

ocaml/database/db_globs.mli

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 redo_log_block_device_io : string ref
16+
17+
val redo_log_connect_delay : float ref
18+
19+
val redo_log_max_block_time_empty : float ref
20+
21+
val redo_log_max_block_time_read : float ref
22+
23+
val redo_log_max_block_time_writedelta : float ref
24+
25+
val redo_log_max_block_time_writedb : float ref
26+
27+
val redo_log_initial_backoff_delay : int
28+
29+
val redo_log_exponentiation_base : int
30+
31+
val redo_log_maximum_backoff_delay : int
32+
33+
val redo_log_max_dying_processes : int
34+
35+
val redo_log_comms_socket_stem : string
36+
37+
val redo_log_max_startup_time : float ref
38+
39+
val redo_log_length_of_half : int
40+
41+
val ha_metadata_db : string
42+
43+
val gen_metadata_db : string
44+
45+
val static_vdis_dir : string ref
46+
47+
val http_limit_max_rpc_size : int
48+
49+
val idempotent_map : bool ref
50+
51+
val permanent_master_failure_retry_interval : float ref
52+
53+
val master_connection_reset_timeout : float ref
54+
55+
val master_connection_retry_timeout : float ref
56+
57+
val master_connection_default_timeout : float ref
58+
59+
val pool_secret : Db_secret_string.t ref
60+
61+
val restart_fn : (unit -> unit) ref
62+
63+
val https_port : int ref
64+
65+
val snapshot_db : string
66+
67+
val db_conf_path : string ref
File renamed without changes.

0 commit comments

Comments
 (0)