The cycle form
Each key of an aspect gives one element. For 0 to n elements, or to ask the tree for data, write a component
under cycle. As in Cycle.js, a component is a function from sources to sinks.
Its sources are tree, scope and one source for each sink. It returns sinks by name, and tree requests.
# A component: it reads sources (the tree, the sinks) and writes sinks. It gives 0 to n elements.{ yen, ... }:{ yen.aspects.vm-network = { at = yen.lib.has yen.kinds.guest; # every host with a guest cycle = { tree, ... }: { tree = [ { category = "vms"; children = yen.kinds.guest; } ]; # a request: the guest children bridges = map (g: "br-${g.name}") (builtins.head (tree.select "vms")); # one element per guest errors = [ ]; }; };}The host has two guests, so the component gives two bridges:
{ server = [ "br-ci" "br-db" ];}Tree requests
Section titled “Tree requests”A request has a category and one question. tree.select category gives the answers.
| Request | Answer |
|---|---|
nearest = yen.kinds.environment | the nearest scope of that kind |
parent = true | the parent scope |
children = predicate | the children where the predicate holds |
scopesOf = instance | every scope of an instance |
holds = predicate | true or false at this scope |