Explorer

definy.read-definitions

description
Read the contents of the CAS as part definitions. Each content is read once per isolate (the host caches it). Contents not in the CAS are left out
type
Fn(
  content_hashes: List<String>,
  then: Fn(definitions: List<@definy.definition-cache-entry>) -> @definy.service-io
) -> @definy.service-io
expression
fn(content_hashes$0, then$1) =>
  let hashes$2 = @definy.strings-unique(items: $0);
  #read_cached_definitions<@definy.service-io>({
    version: @definy.definition-cache-version,
    content_hashes: $2,
    then: fn(cached$3) =>
      let missing$4 = @definy.uncached-hashes(hashes: $2, cached: $3, index: 0, result: []);
      match @core.equal(left: @core.list-length(value: $4), right: 0) {
        true =>
          $1(definitions: $3),
        false =>
          @definy.store-read-contents(
            content_hashes: $4,
            then: fn(items$5) =>
              let fresh$6 = @definy.definition-entries-of(items: $5, index: 0, result: []);
              #write_cached_definitions<@definy.service-io>({
                version: @definy.definition-cache-version,
                entries: $6,
                then: fn(written$7) =>
                  $1(definitions: @core.list-concat(left: $3, right: $6))
              })
          )
      }
  })
visibility
public
definy.read-definitions (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: HxEc9HdJM4uOs2J-EJQo376euZc896kpqEipiJWYxj0
content hash: s6Zz4gBZrg6aPA6V1Fs3nFtyPRke659NiArEgIGLVcw