Module Cache.MessagesSource

Sourcetype version = {
  1. major : int;
  2. minor : int;
}

A version of the communication protocol between Dune and the cache daemon.

Sourcetype promotion = {
  1. key : Key.t;
  2. files : (Stdune.Path.Build.t * Stdune.Digest.t) list;
  3. metadata : Stdune.Sexp.t list;
  4. repository : int option;
  5. duplication : Cache__.Cache_intf.Duplication_mode.t option;
}

When Dune successfully executes a build rule, it sends a "promotion" message to the cache daemon, listing the produced files along with some metadata and a few other fields relevant for caching.

Sourcetype initial =
  1. | Initial

There is one initial message Lang, which is sent by Dune and the cache daemon to each other during the initial negotiation of the version of the communication protocol.

Sourcetype outgoing =
  1. | Outgoing

Outgoing messages are sent by Dune to the cache daemon.

Sourcetype incoming =
  1. | Incoming

Incoming messages are sent by the cache daemon to Dune.

Sourcetype _ message =
  1. | Lang : version list -> initial message
    (*

    Inform the other party about the supported versions of the communication protocol.

    *)
  2. | SetBuildRoot : Stdune.Path.t -> outgoing message
    (*

    Set the absolute path to the build root, to be used when interpreting relative paths in subsequent messages.

    *)
  3. | SetCommonMetadata : Stdune.Sexp.t list -> outgoing message
    (*

    Set the common metadata that should be added to the subsequent Promote messages.

    *)
  4. | SetRepos : Cache__.Cache_intf.repository list -> outgoing message
    (*

    Set the paths to all the version controlled repositories in the workspace along with the associated commit identifiers.

    *)
  5. | Promote : promotion -> outgoing message
    (*

    Promote files produced by a build rule into the cache.

    *)
  6. | Hint : Stdune.Digest.t list -> outgoing message
    (*

    The cache daemon a rule is going to be built

    *)
  7. | Dedup : Cache__.Cache_intf.File.t -> incoming message
    (*

    Inform Dune that a file that was previously promoted can now be replaced by a hardlink to the corresponding file stored in cache.

    *)

Messages of the communication protocol between Dune and the cache daemon.

Sourceval incoming_message_of_sexp : version -> Stdune.Sexp.t -> (incoming message, string) Stdune.Result.t

Decode an incoming message.

Sourceval initial_message_of_sexp : Stdune.Sexp.t -> (initial message, string) Stdune.Result.t

Decode an initial message.

Sourceval outgoing_message_of_sexp : version -> Stdune.Sexp.t -> (outgoing message, string) Stdune.Result.t

Decode an outgoing message.

Sourceval sexp_of_message : version -> 'a message -> Stdune.Sexp.t

Encode a message.

Sourceval send : version -> out_channel -> 'a message -> unit

Send a message.

Sourceval negotiate_version : versions_supported_by_dune:version list -> Unix.file_descr -> in_channel -> out_channel -> (version, string) Stdune.result

Find the newest version of the communication protocol supported both by Dune and the cache daemon. To do that, we send versions_supported_by_dune to the cache daemon via the out_channel, receive the supported versions of the cache daemon via the in_channel, and pick the newest one that matches both lists.

Sourceval string_of_version : version -> string
Sourceval hint_supported : version -> bool
Sourceval hint_min_version : version
Sourceval find_newest_common_version : version list -> version list -> (version, string) Stdune.result