1ae1e84d832133ebda0cbfb6fecf7252e9d663c3
[khatus.git] / x3 / src / exe / khatus_cache_dumper.ml
1 open Khatus
2
3 let main ~stream ~interval ~dir =
4 let dumped = Time.init in
5 ignore (Msg_stream.fold stream ~init:dumped ~f:(
6 fun dumped ~state:(State.({node; modul; time = now; cache;})) ~msg:_ ->
7 let elapsed = Time.diff dumped now in
8 if (Time.Span.is_gt_or_eq elapsed interval)
9 then begin
10 Cache.dump_to_dir cache ~time:now ~node ~modul ~dir;
11 now
12 end else
13 dumped
14 ))
15
16 let () =
17 let modul = __MODULE__ in
18 let node = Sys.argv.(1) in
19 let dump_interval = Sys.argv.(2) |> Time.Span.of_string in
20 let dump_directory = Sys.argv.(3) in
21 main
22 ~stream: (Msg_stream.init ~node ~modul)
23 ~interval: dump_interval
24 ~dir: dump_directory
This page took 0.103272 seconds and 4 git commands to generate.