package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=dbc3b675aee59c2c574e5d0a771193a2ecfca31e7a5bc5aed66598080596ce1c
sha512=b97ed762b9d24744305c358af0d20f394376b64bfdd758dd4a81775326caf445caa57c4f6445da3dd6468ff492de18e4c14af6f374dfcbb7e4d64b7b720e5e2a
doc/octez-libs.requester/Tezos_requester/Requester_impl/Make_memory_full_requester/index.html
Module Requester_impl.Make_memory_full_requester
Source
A helper to avoid having to use the full-fledged Requester.Make
* functor. We take the Requester.REQUEST
module as parameter (instead * of hardcoding the use of Simple_request
), because * callers that use Simple_request
likely want to observe * the underlying effects (see the ref
in Simple_request
) and hence * want to pass their own instance. * * Like Requester.Make
, this returns an instance of FULL_REQUESTER
. * Note that, contrary to a production requester, the instance returned * by this functor does not use the disk, it runs entirely in memory.
Parameters
module H : Requester.HASH
module P : PARAMETERS with type key = H.t
module R : Requester.REQUEST with type param = unit and type key = H.t
Signature
include Requester.REQUESTER
with type key = H.t
with type value = P.value
with type param = bool
validation clue
know t k
returns true iff the key is present in the memory table or the disk.
Return value if it is found in-memory, or else on disk. Otherwise fail with error Missing_data
.
inject t k v
returns false
if k
is already present in the memory table or in the disk, or has already been requested. Otherwise it updates the memory table and return true
val fetch :
t ->
?peer:Tezos_base.TzPervasives.P2p_peer.Id.t ->
?timeout:Tezos_base.TzPervasives.Time.System.Span.t ->
key ->
param ->
value Tezos_base.TzPervasives.tzresult Lwt.t
fetch t ?peer ?timeout k param
returns the value when it is known. It can fail with Timeout k
if timeout
is provided and the value isn't know before the timeout expires. It can fail with Cancel
if the request is canceled.
The key is first looked up in memory, then on disk. If not present and not already requested, it schedules a request, and blocks until the requester is notified with notify
. param
is used to validate the notified value once it is received. (see also PROBE
and notify
).
Requests are re-sent via a 1.5 exponential back-off, with initial delay set to Request.initial_delay
. If the function is called multiple time with the same key but with distinct peers, the internal scheduler randomly chooses the requested peer (at each retry).
The "disk" storage
Configuration parameter to the Request
service
Monitor all the fetched data. A given data will appear only once.
val notify :
t ->
Tezos_base.TzPervasives.P2p_peer.Id.t ->
key ->
notified_value ->
unit Lwt.t
notify t peer k nv
notifies the requester that a value has been received for key k
, from peer peer
. nv
is a *notified value*. The notified value is validated using Probe.probe
, and the param
provided at fetching time (see PROBE
). If valid, the memory table is updated and all promises waiting on this key are resolved.
If the key is not pending the notification is ignored.
memory_table_length t
returns the number of keys either known or pending in the memory table of t
val create :
?random_table:bool ->
?global_input:(key * value) Lwt_watcher.input ->
request_param ->
store ->
t
create ?random_table ?global_input r s
creates a requester. r
is the configuration parameter passed to Request
functions.
The value for random_table
determines whether the underlying hashtable randomises its hash (see Stdlib.Hashtbl.create
and specifically the documentation of the random
parameter). The default depends on environment variables and Stdlib.Hashtbl.randomize
has been called.