Skip to content

Commit

Permalink
Rename UpdateClientItf to S
Browse files Browse the repository at this point in the history
  • Loading branch information
yfyf committed Aug 26, 2024
1 parent 7b762bb commit 5e009c3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions controller/server/rauc_service.ml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 =
Expand All @@ -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 () =
Expand Down
6 changes: 3 additions & 3 deletions controller/server/rauc_service.mli
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
4 changes: 2 additions & 2 deletions controller/server/update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions controller/server/update.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions controller/server/update_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions controller/server/update_client.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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` *)
Expand All @@ -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
8 changes: 4 additions & 4 deletions controller/tests/update_client_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 5e009c3

Please sign in to comment.