package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
doc/octez-libs.requester/Tezos_requester/Requester/index.html
Module Tezos_requester.Requester
Source
Generic resource fetching/requesting service.
This module defines a generic resource fetching service Requester
. It is parameterized by abstract services Disk
, Request
, Memory_table
and Probe
.
It offers a key/value store interface. Values are looked up successively in Memory_table.t
, then in Disk.store
. If not found, they are *requested* using the Request
service. Ultimately, values are *cached* in the Memory_table
for faster retrieval on subsequent queries. This is similar to a *read-through* cache except that values are never evicted from the Memory_table
.
Internally, the service schedules requests to an abstract external source (e.g. network) for missing keys. The key is then *pending* and the caller waits for the value to be available.
When a value is missing, the requester sends a request via Request.send
to query a value to the network. The requester must be *notified* by an external component when the requested value is available using Requester.notify
.
Notified values are validated before being inserted in the requester, using the Probe
module.
The full resource fetching service is realized by the conjunction of two components. The requester component, defined by this library, and a notifying component (for instance, a worker thread waiting for network messages).
The requester offers two interfaces. FULL_REQUESTER
is the full view, which includes the creation, shutdown, and notification functions. It is to be used by the controller setting up the service, and the notifying component. REQUESTER
is the restricted view, exported to the service final user.
Requests
abstracts a service used to send asynchronous key requests to peers.
When a requested value is received, it goes to a validation phase.
module Make
(Hash : HASH)
(Disk_table : DISK_TABLE with type key := Hash.t)
(Memory_table : MEMORY_TABLE with type key := Hash.t)
(Request : REQUEST with type key := Hash.t)
(Probe : PROBE with type key := Hash.t and type value := Disk_table.value) :
FULL_REQUESTER
with type key = Hash.t
and type value = Disk_table.value
and type param = Probe.param
and type request_param = Request.param
and type notified_value = Probe.notified_value
and type store = Disk_table.store