mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-05 19:00:33 -05:00
feat(trace): add Source, to read traces
This commit is contained in:
parent
ca3262eac3
commit
f2471fd78c
3 changed files with 38 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ open Sidekick_sigs
|
|||
module Entry_view = Entry_view
|
||||
module Entry_read = Entry_read
|
||||
module Sink = Sink
|
||||
module Source = Source
|
||||
module Entry_id = Entry_id
|
||||
|
||||
type entry_id = Entry_id.t
|
||||
|
|
|
|||
15
src/trace/source.ml
Normal file
15
src/trace/source.ml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
type tag = string
|
||||
|
||||
module type S = sig
|
||||
val get_entry : Entry_id.t -> tag * Ser_value.t
|
||||
val iter_all : (Entry_id.t -> tag:tag -> Ser_value.t -> unit) -> unit
|
||||
end
|
||||
|
||||
type t = (module S)
|
||||
|
||||
let get_entry_exn (module S : S) id = S.get_entry id
|
||||
|
||||
let get_entry (module S : S) id : _ option =
|
||||
try Some (S.get_entry id) with Not_found -> None
|
||||
|
||||
let iter_all (module S : S) f : unit = S.iter_all f
|
||||
22
src/trace/source.mli
Normal file
22
src/trace/source.mli
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(** Source to read a trace.
|
||||
|
||||
A source is an IO input source that allows the read of individual
|
||||
entries of the trace, by providing their entry ID. It also allows to
|
||||
iterate on entries in chronological order.
|
||||
*)
|
||||
|
||||
type tag = string
|
||||
|
||||
module type S = sig
|
||||
val get_entry : Entry_id.t -> tag * Ser_value.t
|
||||
(** @raise Not_found if there is no such entry *)
|
||||
|
||||
val iter_all : (Entry_id.t -> tag:tag -> Ser_value.t -> unit) -> unit
|
||||
(** Iterate on all entries *)
|
||||
end
|
||||
|
||||
type t = (module S)
|
||||
|
||||
val get_entry : t -> Entry_id.t -> (tag * Ser_value.t) option
|
||||
val get_entry_exn : t -> Entry_id.t -> tag * Ser_value.t
|
||||
val iter_all : t -> (Entry_id.t -> tag:tag -> Ser_value.t -> unit) -> unit
|
||||
Loading…
Add table
Reference in a new issue