✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

The Mediator

A centralized ethereal router that orchestrates complex communications between disparate Gallina Wards.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Abjuration // Networking
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
(* Gallina Ward: Mediator *)
Require Import String.

(* Ward interfaces passing messages to a central mediator *)
Record SystemMediator := {
  notify : string -> string -> string
}.

Record Node := {
  id : string;
  med : SystemMediator;
  send : string -> string
}.

Definition makeNode (n_id : string) (m : SystemMediator) : Node := {|
  id := n_id;
  med := m;
  send := fun ev => m.(notify) n_id ev
|}.

Definition nexusMediator : SystemMediator := {|
  notify := fun sender event =>
    "Nexus received " ++ event ++ " from " ++ sender ++ ". Routing accordingly..."
|}.

Definition alphaNode := makeNode "Alpha" nexusMediator.
Definition eventResult := alphaNode.(send) "Overload".
Runic Tags: #mediator #gallina #wards