package octez-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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.

module type REQUESTER = sig ... end
module type FULL_REQUESTER = sig ... end
module type DISK_TABLE = sig ... end
module type MEMORY_TABLE = sig ... end
module type REQUEST = sig ... end

Requests abstracts a service used to send asynchronous key requests to peers.

module type PROBE = sig ... end

When a requested value is received, it goes to a validation phase.

module type HASH = sig ... end

An input module of Make

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
OCaml

Innovation. Community. Security.