package datakit-ci

  1. Overview
  2. Docs

Builder

type t

The type for builder values. A builder generates values from inputs (keys). A builder is typically used with a cache.

module Key : sig ... end

Input describing what is to be built. Any change to the key will trigger a rebuild. If you want to use some value in the build but not rebuild when it changes, put it in the context instead.

type context

For passing context parameters to the builder which aren't part of the key (e.g. timeouts or resource pools).

type value

Output of the builder.

val name : t -> string

A unique name for this builder. This is used for metric reporting.

val title : t -> Key.t -> string

title t key is a one-line summary of the operation that is performed by generate. It is used as the reason string for the pending state and as the title of the log.

val generate : t -> switch:Lwt_switch.t -> log:Live_log.t -> DK.Transaction.t -> context -> Key.t -> (value, [ `Failure of string ]) result Lwt.t

generate t ~log trans ctx key generates the value for key and stores it in trans under the "value" directory. It is called when the value is not in the cache, or when a rebuild has been requested. The value returned must be the same as the value that would be loaded by load. If the build is cancelled, switch will be turned off. If generate throws an exception then it is caught and treated as an error result.

val load : t -> DK.Tree.t -> Key.t -> value Lwt.t

load t tr key is the value v previously saved by generate.

val branch : t -> Key.t -> string

The name of the DataKit branch on which to store the result for this key. If the branch exists and is up-to-date then we use that instead of rebuilding. Changes to the key *must* result in a different branch name.