A timeseries store implementation which fulfills TS_SIG
val create : endpoint:string ‑> Utils.databox_ctx ‑> ?logging:bool ‑> unit ‑> t
create store_uri ctx ?logging ()
creates a timeseries store instance.
store_uri
could be read from Utils.store_endpoint, ctx
could be returned
from Utils.databox_init, logging
defaults to false
.
val register_datasource : t ‑> meta:Store_datasource.meta ‑> unit Lwt.t
val write : t ‑> datasource_id:string ‑> payload:Ezjsonm.t ‑> unit Lwt.t
val write_at : t ‑> datasource_id:string ‑> ts:int64 ‑> payload:Ezjsonm.t ‑> unit Lwt.t
All data loaded will be attached with a timestamp, for example:
{ timestamp: 1516633601325, data: [ {temperature: 10.7, long:-0.127758, lat:51.507351, loc: "London" }, {temperature: -4.1, long:116.407396 lat:39.904200, loc: "Beijing"}, {temperature: 5.6, long:-122.332071 lat:47.606209, loc: "Seattle"}, ] }
Data from data
field above is whatever data written into the store by the write functions.
For functions last_n, first_n, since, range, the returned result
will be an array of elements of such format.
val latest : t ‑> datasource_id:string ‑> Ezjsonm.t Lwt.t
val earliest : t ‑> datasource_id:string ‑> Ezjsonm.t Lwt.t
val last_n : t ‑> datasource_id:string ‑> int ‑> Ezjsonm.t Lwt.t
val first_n : t ‑> datasource_id:string ‑> int ‑> Ezjsonm.t Lwt.t
val since : t ‑> datasource_id:string ‑> since_ts:int64 ‑> Ezjsonm.t Lwt.t
val range : t ‑> datasource_id:string ‑> from_ts:int64 ‑> to_ts:int64 ‑> Ezjsonm.t Lwt.t
range t ~datasource_id ~from_ts ~to_ts
, the from_ts
and to_ts
are both inclusive
when the store loads the data
val observe : t ‑> datasource_id:string ‑> ?timeout:int ‑> unit ‑> Ezjsonm.t Lwt_stream.t Lwt.t
observe t ~datasource_id ?timeout ()
returns a stream from which each new
value written to datasource_id
could be feteched.
timeout
defaults to 0, which means observing until TS_SIG.stop_observing is called,
unit is seconds.
val stop_observing : t ‑> datasource_id:string ‑> unit Lwt.t