1 module Time = Khatus_time
4 | Alert of {priority : [`low | `med | `hi]; subject : string; body : string}
5 | Data of {key : string list; value : string}
14 | Log of {location : string; level : [`info | `error]; msg : string}
15 | Status_bar of string
18 {node : string; modul : string; content : content}
20 type 'a data_handler =
21 node:string -> modul:string -> key:string list -> value:string -> 'a
26 let to_string {node; modul; content} =
28 | Alert {priority; subject; body} ->
35 String.concat sep_1 [node; modul; "alert"; priority; subject; body]
36 | Data {key; value} ->
37 let key = String.concat sep_2 key in
38 String.concat sep_1 [node; modul; "data"; key; value]
39 | Cache {mtime; node=node'; modul=modul'; key; value} ->
40 let key = String.concat sep_2 key in
41 let mtime = Time.to_string mtime in
44 [node; modul; "cache"; mtime; node'; modul'; key; value]
46 String.concat sep_1 [node; modul; "error"; text]
47 | Log {location; level; msg} ->
53 String.concat sep_1 [node; modul; "log"; location; level; msg]
55 String.concat sep_1 [node; modul; "status_bar"; text]
57 let handle_data t ~f ~otherwise =
59 | {content = Data {key; value}; node; modul} ->
60 f ~node ~modul ~key ~value
61 | {content = Alert _; _}
62 | {content = Cache _; _}
63 | {content = Error _; _}
64 | {content = Log _; _}
65 | {content = Status_bar _; _}