From 5e009c3e847752e370355893fdb13a81b3b32846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Mon, 26 Aug 2024 09:10:01 +0300 Subject: [PATCH] Rename UpdateClientItf to S --- controller/server/rauc_service.ml | 6 +++--- controller/server/rauc_service.mli | 6 +++--- controller/server/update.ml | 4 ++-- controller/server/update.mli | 4 ++-- controller/server/update_client.ml | 4 ++-- controller/server/update_client.mli | 8 ++++---- controller/tests/update_client_tests.ml | 8 ++++---- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/controller/server/rauc_service.ml b/controller/server/rauc_service.ml index 1bbb880f..d02288a9 100644 --- a/controller/server/rauc_service.ml +++ b/controller/server/rauc_service.ml @@ -1,4 +1,4 @@ -module type RaucServiceIntf = sig +module type S = sig (** [get_status unit] returns current RAUC status *) val get_status : unit -> Rauc.status Lwt.t @@ -15,7 +15,7 @@ module type RaucServiceIntf = sig val install : string -> unit Lwt.t end -module RaucOBus(OBusRef: sig val peer: Rauc.t end): RaucServiceIntf = struct +module RaucOBus(OBusRef: sig val peer: Rauc.t end): S = struct let t = OBusRef.peer let get_status () : Rauc.status Lwt.t = @@ -34,7 +34,7 @@ module RaucOBus(OBusRef: sig val peer: Rauc.t end): RaucServiceIntf = struct Rauc.install t end -let build_module rauc_peer : (module RaucServiceIntf) = +let build_module rauc_peer : (module S) = (module RaucOBus (struct let peer = rauc_peer end)) let init () = diff --git a/controller/server/rauc_service.mli b/controller/server/rauc_service.mli index c5f7c205..4eb741e7 100644 --- a/controller/server/rauc_service.mli +++ b/controller/server/rauc_service.mli @@ -1,7 +1,7 @@ (* would suggest moving this to `rauc_service_intf.ml` and using `include`s (jane-street-style) to avoid having to duplicate it in the .ml files *) -module type RaucServiceIntf = sig +module type S = sig (** [get_status unit] returns current RAUC status *) val get_status : unit -> Rauc.status Lwt.t @@ -18,9 +18,9 @@ module type RaucServiceIntf = sig val install : string -> unit Lwt.t end -val init : unit -> (module RaucServiceIntf) Lwt.t +val init : unit -> (module S) Lwt.t (* NOTE: only exposed now to enable partial refactoring. In the final impl only `init` is called once at the top-level (server module) and then the module/interface is passed to dependencies (Update, Gui, Health) directly *) -val build_module : Rauc.t -> (module RaucServiceIntf) +val build_module : Rauc.t -> (module S) diff --git a/controller/server/update.ml b/controller/server/update.ml index 2fa90dac..eb059c37 100644 --- a/controller/server/update.ml +++ b/controller/server/update.ml @@ -42,8 +42,8 @@ type config = { } module type ServiceDeps = sig - module ClientI: Update_client.UpdateClientIntf - module RaucI: Rauc_service.RaucServiceIntf + module ClientI: Update_client.S + module RaucI: Rauc_service.S val config : config end diff --git a/controller/server/update.mli b/controller/server/update.mli index 63cb954c..1097347f 100644 --- a/controller/server/update.mli +++ b/controller/server/update.mli @@ -37,8 +37,8 @@ type config = { } module type ServiceDeps = sig - module ClientI: Update_client.UpdateClientIntf - module RaucI: Rauc_service.RaucServiceIntf + module ClientI: Update_client.S + module RaucI: Rauc_service.S val config : config end diff --git a/controller/server/update_client.ml b/controller/server/update_client.ml index f692afd7..07b08b84 100644 --- a/controller/server/update_client.ml +++ b/controller/server/update_client.ml @@ -5,7 +5,7 @@ type version = string (* local filesystem path *) type bundle_path = string -module type UpdateClientIntf = sig +module type S = sig (* download bundle from specified url and save it as `version` *) val download : Uri.t -> version -> bundle_path Lwt.t @@ -90,4 +90,4 @@ let init connman = let%lwt connman = Connman.Manager.connect () in *) let%lwt proxy = get_proxy_uri connman in let configI = make_config ?proxy Config.System.update_url in - Lwt.return @@ (module UpdateClient (val configI : UpdateClientConfig) : UpdateClientIntf) + Lwt.return @@ (module UpdateClient (val configI : UpdateClientConfig) : S) diff --git a/controller/server/update_client.mli b/controller/server/update_client.mli index a9750b99..fdb116b6 100644 --- a/controller/server/update_client.mli +++ b/controller/server/update_client.mli @@ -6,7 +6,7 @@ type version = string (* local filesystem path *) type bundle_path = string -module type UpdateClientIntf = sig +module type S = sig (* TODO: this method is currently overspecified, it should probably provide only the version and the client should resolve the URL *) (* download bundle from specified url and save it as `version` *) @@ -27,9 +27,9 @@ end val make_config : ?proxy:Uri.t -> string -> (module UpdateClientConfig) -module Make (ConfigI : UpdateClientConfig) : UpdateClientIntf +module Make (ConfigI : UpdateClientConfig) : S (* Suggested interface after broader refactoring - val init : unit -> (module UpdateClientIntf) Lwt.t + val init : unit -> (module S) Lwt.t *) -val init : Connman.Manager.t -> (module UpdateClientIntf) Lwt.t +val init : Connman.Manager.t -> (module S) Lwt.t diff --git a/controller/tests/update_client_tests.ml b/controller/tests/update_client_tests.ml index c6558907..64131bf0 100644 --- a/controller/tests/update_client_tests.ml +++ b/controller/tests/update_client_tests.ml @@ -118,9 +118,9 @@ let run_test_case ?(proxy = NoProxy) switch f = let (proxy_url, base_url) = process_proxy_spec proxy server_url in let module ConfigI = (val Update_client.make_config ?proxy:proxy_url base_url) in let module UpdateC = Update_client.Make (ConfigI) in - f (module UpdateC : UpdateClientIntf) + f (module UpdateC : S) -let test_get_version_ok (module Client : UpdateClientIntf) = +let test_get_version_ok (module Client : S) = let expected_version = "1.0.0" in let () = StubServer.set_latest_version expected_version in let%lwt vsn = Client.get_latest_version () in @@ -131,7 +131,7 @@ let test_get_version_ok (module Client : UpdateClientIntf) = let read_file file = In_channel.with_open_bin file In_channel.input_all -let test_download_bundle_ok (module Client : UpdateClientIntf) = +let test_download_bundle_ok (module Client : S) = let version = "1.0.0" in let bundle = "BUNDLE_CONTENTS" in let () = StubServer.add_bundle version bundle in @@ -148,7 +148,7 @@ let test_download_bundle_ok (module Client : UpdateClientIntf) = return () (* invalid proxy URL is set in the `run_test_case` function, see below *) -let test_invalid_proxy_fail (module Client : UpdateClientIntf) = +let test_invalid_proxy_fail (module Client : S) = Lwt.try_bind Client.get_latest_version (fun _ -> Alcotest.fail "Get version was supposed to fail due to invalid proxy")