123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226(*
* Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)(** Irmin signatures *)open!Importtypeconfig=Conf.tmoduleStore_properties=structmoduletypeBATCH=sigtype'atvalbatch:readt->([read|write]t->'aLwt.t)->'aLwt.t(** [batch t f] applies the writes in [f] in a separate batch. The exact
guarantees depend on the implementation. *)endmoduletypeCLOSEABLE=sigtype'atvalclose:'at->unitLwt.t(** [close t] frees up all the resources associated with [t]. Any operations
run on a closed handle will raise {!Closed}. *)endmoduletypeOF_CONFIG=sigtype'atvalv:config->readtLwt.t(** [v config] is a function returning fresh store handles, with the
configuration [config], which is provided by the backend. *)endmoduletypeCLEARABLE=sigtype'atvalclear:'at->unitLwt.t(** Clear the store. This operation is expected to be slow. *)endendopenStore_propertiesmoduletypeCONTENT_ADDRESSABLE_STORE=sig(** {1 Content-addressable stores}
Content-addressable stores are store where it is possible to read and add
new values. Keys are derived from the values raw contents and hence are
deterministic. *)type-'at(** The type for content-addressable backend stores. The ['a] phantom type
carries information about the store mutability. *)typekey(** The type for keys. *)typevalue(** The type for raw values. *)valmem:[>read]t->key->boolLwt.t(** [mem t k] is true iff [k] is present in [t]. *)valfind:[>read]t->key->valueoptionLwt.t(** [find t k] is [Some v] if [k] is associated to [v] in [t] and [None] is
[k] is not present in [t]. *)valadd:[>write]t->value->keyLwt.t(** Write the contents of a value to the store. It's the responsibility of the
content-addressable store to generate a consistent key. *)valunsafe_add:[>write]t->key->value->unitLwt.t(** Same as {!add} but allows to specify the key directly. The backend might
choose to discared that key and/or can be corrupt if the key scheme is not
consistent. *)includeCLEARABLEwithtype'at:='atendmoduletypeCONTENT_ADDRESSABLE_STORE_MAKER=functor(K:Hash.S)(V:Type.S)->sigincludeCONTENT_ADDRESSABLE_STOREwithtypekey=K.tandtypevalue=V.tincludeBATCHwithtype'at:='atincludeOF_CONFIGwithtype'at:='atincludeCLOSEABLEwithtype'at:='atendmoduletypeAPPEND_ONLY_STORE=sig(** {1 Append-only stores}
Append-onlye stores are store where it is possible to read and add new
values. *)type-'at(** The type for append-only backend stores. The ['a] phantom type carries
information about the store mutability. *)typekey(** The type for keys. *)typevalue(** The type for raw values. *)valmem:[>read]t->key->boolLwt.t(** [mem t k] is true iff [k] is present in [t]. *)valfind:[>read]t->key->valueoptionLwt.t(** [find t k] is [Some v] if [k] is associated to [v] in [t] and [None] is
[k] is not present in [t]. *)valadd:[>write]t->key->value->unitLwt.t(** Write the contents of a value to the store. *)includeCLEARABLEwithtype'at:='atendmoduletypeAPPEND_ONLY_STORE_MAKER=functor(K:Type.S)(V:Type.S)->sigincludeAPPEND_ONLY_STOREwithtypekey=K.tandtypevalue=V.tincludeBATCHwithtype'at:='atincludeOF_CONFIGwithtype'at:='atincludeCLOSEABLEwithtype'at:='atendmoduletypeMETADATA=sigtypet[@@derivingirmin](** The type for metadata. *)valmerge:tMerge.t(** [merge] is the merge function for metadata. *)valdefault:t(** The default metadata to attach, for APIs that don't care about metadata. *)endtype'adiff='aDiff.tmoduletypeATOMIC_WRITE_STORE=sig(** {1 Atomic write stores}
Atomic-write stores are stores where it is possible to read, update and
remove elements, with atomically guarantees. *)typet(** The type for atomic-write backend stores. *)typekey(** The type for keys. *)typevalue(** The type for raw values. *)valmem:t->key->boolLwt.t(** [mem t k] is true iff [k] is present in [t]. *)valfind:t->key->valueoptionLwt.t(** [find t k] is [Some v] if [k] is associated to [v] in [t] and [None] is
[k] is not present in [t]. *)valset:t->key->value->unitLwt.t(** [set t k v] replaces the contents of [k] by [v] in [t]. If [k] is not
already defined in [t], create a fresh binding. Raise [Invalid_argument]
if [k] is the {{!Path.empty} empty path}. *)valtest_and_set:t->key->test:valueoption->set:valueoption->boolLwt.t(** [test_and_set t key ~test ~set] sets [key] to [set] only if the current
value of [key] is [test] and in that case returns [true]. If the current
value of [key] is different, it returns [false]. [None] means that the
value does not have to exist or is removed.
{b Note:} The operation is guaranteed to be atomic. *)valremove:t->key->unitLwt.t(** [remove t k] remove the key [k] in [t]. *)vallist:t->keylistLwt.t(** [list t] it the list of keys in [t]. *)typewatch(** The type of watch handlers. *)valwatch:t->?init:(key*value)list->(key->valuediff->unitLwt.t)->watchLwt.t(** [watch t ?init f] adds [f] to the list of [t]'s watch handlers and returns
the watch handler to be used with {!unwatch}. [init] is the optional
initial values. It is more efficient to use {!watch_key} to watch only a
single given key.*)valwatch_key:t->key->?init:value->(valuediff->unitLwt.t)->watchLwt.t(** [watch_key t k ?init f] adds [f] to the list of [t]'s watch handlers for
the key [k] and returns the watch handler to be used with {!unwatch}.
[init] is the optional initial value of the key. *)valunwatch:t->watch->unitLwt.t(** [unwatch t w] removes [w] from [t]'s watch handlers. *)includeCLOSEABLEwithtype_t:=tincludeCLEARABLEwithtype_t:=tendmoduletypeATOMIC_WRITE_STORE_MAKER=functor(K:Type.S)(V:Type.S)->sigincludeATOMIC_WRITE_STOREwithtypekey=K.tandtypevalue=V.tincludeOF_CONFIGwithtype_t:=tendtyperemote=..