allow to specify the number of parallel downloads as boot parameter

This commit is contained in:
Hannes Mehnert 2022-09-25 23:13:52 +02:00
parent b8a369dac8
commit 069643465f
2 changed files with 10 additions and 2 deletions

View file

@ -20,6 +20,14 @@ let remote =
in
Key.(create "remote" Arg.(opt string "https://github.com/ocaml/opam-repository.git#master" doc))
let parallel_downloads =
let doc =
Key.Arg.info
~doc:"Amount of parallel HTTP downloads"
["parallel-downloads"]
in
Key.(create "parallel-downloads" Arg.(opt int 20 doc))
let hook_url =
let doc =
Key.Arg.info
@ -40,7 +48,7 @@ let tls_authenticator =
let mirror =
foreign "Unikernel.Make"
~keys:[ Key.v check ; Key.v remote ; Key.v hook_url ; Key.v tls_authenticator ; Key.v port ]
~keys:[ Key.v check ; Key.v remote ; Key.v parallel_downloads ; Key.v hook_url ; Key.v tls_authenticator ; Key.v port ]
~packages:[
package ~min:"0.1.0" ~sublibs:[ "mirage" ] "paf" ;
package "h2" ;

View file

@ -629,7 +629,7 @@ stamp: %S
"https://github.com/Opsian/opsian-ocaml/releases/download/0.1/0.1.tar.gz"
k)) urls
in
let pool = Lwt_pool.create 20 (Fun.const Lwt.return_unit) in
let pool = Lwt_pool.create (Key_gen.parallel_downloads ()) (Fun.const Lwt.return_unit) in
Lwt_list.iter_p (fun (url, csums) ->
Lwt_pool.use pool @@ fun () ->
HM.fold (fun h v r ->