
Order.pudu
Pudu34 lines1.2 KB
1/** @Mediator.Domain.Order.Module — where each component runs in a pipeline */2module PuduLangMediator.Domain.Order34/** @Mediator.Domain.Order.Layer — the kinds of component a pipeline orders */5export type Layer = Behaviors | PreProcessors | PostProcessors | ExceptionActions | NotificationHandlers | StreamBehaviors67/** @Mediator.Domain.Order.Mark — one registration, open or for one kind */8export type Mark = Open(Layer, Int) | Closed(Layer, Str)910/** @Mediator.Domain.Order.Pick — a shared open component or the kind's own */11export type Pick = Shared(Int) | Own(Int)1213141516export fn picks(marks: &Array[Mark], layer: Layer, name: Str) -> Array[Pick] {17 var found: Array[Pick] = []18 var own = 019 for mark in marks {20 match mark {21 case Open(at, index) => {22 if at == layer { found = found.push(Shared(index)) }23 }24 case Closed(at, owner) => {25 if at == layer && owner == name {26 found = found.push(Own(own))27 own = own + 128 }29 }30 }31 }32 found33}34