package irmin

  1. Overview
  2. Docs

Type agnostics mechanisms to manipulate metrics.

Metrics defines primitives to handle metrics inside of Irmin. Its purpose is to decouple the metrics type definition from the data manipulation.

A t can be modified in different ways, depending on the update_mode.

type origin = ..

An extensible type to get the location of the definition.

type 'a t

t is the object that describes how a t is gathered and store. The 'a parameter represents the type of the internal data.

val state : 'a t -> 'a

The internal state extracted from a t.

val set_state : 'a t -> 'a -> unit

set_state m v updates the value in the t object.

type 'a update_mode =
  1. | Mutate of 'a -> unit
  2. | Replace of 'a -> 'a

update_mode describes how the data will be handled by the update function.

  • Mutate: the value and the storage are not modified but the content of the value can be mutate.
  • Replace f: apply f to the value and updates its content.

It gives the possibility to handle the same metric in different ways.

val v : ?origin:origin -> name:string -> initial_state:'a -> 'a Repr.ty -> 'a t

v ~origin ~name ~initial_state repr create a new t. The origin can be set to give an hint about where the data are gathered. name is a name to describe this metrics. initial_state is the first value to store in the metric object. repr describes the type representation to allow serialization.

val update : 'a t -> 'a update_mode -> unit

update metrics mode updates the metric by taking in consideration mode to define how it acts on t according to their specication.

OCaml

Innovation. Community. Security.