execution_resource_description.bend
bendvy-ecs-core@0.1.0.3 · 21 lines · 4 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/execution_resource_policy.bend as Policy
3import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as L
4import bendvy-ecs-core@0.1.0.3/execution_query_schema.bend as Routes
5import bendvy-ecs-core@0.1.0.3/owner_product.bend as Product
6import bendvy-ecs-core@0.1.0.3/lifecycle.bend as Life
7
8type Info is Data:
9 Info{route:L.Route,key:String,stamp:Life.Stamp}
10type Description<-S:Data,-full:L.Layout> is Type:
11 Description{resources:L.resources(~S,full),info:List<&2,Info>}
12def described_pair(~S:Data,-ll:L.Layout,-rr:L.Layout,left:Description<S,ll>,right:Description<S,rr>) -> Description<S,L.LayoutPair{ll,rr}>:
13 match left right:
14 case Description{left,li} Description{right,ri}:Description{Product.Owner{left,right},List.append(&2,Info,li,ri)}
15
16def describe(~S:Data,layout:L.Layout,+route:L.Route,resources:L.resources(~S,layout)) -> Description<S,layout>:
17 match layout resources:
18 case L.EmptyLayout{} Unit{}:Description{Unit{},[]}
19 case L.LayoutLeaf{P,V,refresh,+key,_} L.ResourceSlot{owner,+stamp}:Description{L.ResourceSlot{owner,stamp},[Info{route,key,stamp}]}
20 case L.ClassifiedLayoutLeaf{P,V,refresh,+key,kind,_} L.ResourceSlot{owner,+stamp}:Description{L.ResourceSlot{owner,stamp},[Info{route,key,stamp}]}
21 case L.LayoutPair{ll,rr} Product.Owner{left,right}:described_pair(~S,ll,rr,describe(~S,ll,Routes.append_route(route,L.InLeft{L.AtLeaf{}}),left),describe(~S,rr,Routes.append_route(route,L.InRight{L.AtLeaf{}}),right))