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

Census.pudu

Pudu24 lines1.1 KB

GitHub ↗
1/** @Mediator.Domain.Census.Module — what a registered kind is missing or has twice */2module PuduLangMediator.Domain.Census34import PuduLangMediator.Constants.Messages as Messages5import PuduLangMediator.Utils.Template as Template67/** @Mediator.Domain.Census.Census — the registrations counted for one kind */8export type Census = { name: Str, handlers: Int, components: Int, collisions: Int, single: Bool }910/// Every problem with one kind's registrations: a missing name, a name two kinds share, and, for11/// a kind that takes exactly one handler, more than one or components without any.12export fn problems(census: &Census) -> Array[Str] {13  var found: Array[Str] = []14  if census.name.isEmpty() { found = found.push(Messages.EMPTY_NAME) }15  if census.collisions > 0 { found = found.push(Template.fill(Messages.NAME_TAKEN, &[census.name])) }16  if census.single && census.handlers > 1 {17    found = found.push(Template.fill(Messages.DUPLICATE_HANDLER, &[census.name, show(census.handlers)]))18  }19  if census.single && census.handlers == 0 && census.components > 0 {20    found = found.push(Template.fill(Messages.WITHOUT_HANDLER, &[census.name]))21  }22  found23}24