Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-mediator

In-process messaging for Pudu: requests, notifications, streams, pipeline behaviors, processors, and exception handling

0.1.0Apache-2.01

InstallClose

Order.pudu

Pudu34 lines1.2 KB

GitHub ↗
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)1213/// The components of one layer that apply to the kind named `name`, in registration order: every14/// open one by its index among open components, and each of the kind's own by its index among15/// the kind's own.16export 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