Skip to main content

Module op_templates

Module op_templates 

Source
Expand description

Op templates: reusable op definitions an op instantiates with uses:.

A document’s top-level op_templates: maps a template name to an op body — typically a protocol request shape (an http method / uri / body) with a typed abstract: interface naming the wires it needs. The templates run nowhere by themselves. An op in a phase, a block, or the top-level ops: instantiates one:

extends: petstore_ops           # a library of op_templates
phases:
  read:
    cycles: 1000
    ops:
      fetch:
        uses: getPetById        # the template
        bindings: |             # qualifies what it needs
          petId := mod(hash(cycle), 1000)

Resolution is a load-time document rewrite, before ops are parsed: the op’s body becomes the template’s body with the op’s own keys folded in, so everything downstream sees an ordinary op. The rules follow SRD-108’s binder: a key both sides declare is a load error (a template’s request shape is fixed), except params — the override surface, where the op re-defaults — and tags, which merge with the op’s winning. The instantiated op keeps the template’s abstract: interface as a bound interface: the parser checks that every needs wire is supplied, and pre-map synthesis type-checks it like any bound SRD-108 slot.

Constants§

OP_TEMPLATES_KEY
The document key that declares op templates.
USES_KEY
The op key that instantiates a template.