package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
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